
# line 6 "proj1.yac"
#include <stdio.h>
#include <string.h>

/* The parse stack type is a pointer to void in order that rule can */
/* return two types of items: strings and lists of strings. */
typedef void *STK_TYP;
#define YYSTYPE STK_TYP

/* A handy macro for printing quads (the label and fields 1-4). */
#define PRINT_QUAD(a,b,c,d,e)	printf("%s\t%s\t%s\t%s\t%s\n",a,b,c,d,e)

/* miscellaneous character variables */
char *temp, *temp1, *temp2;

/* Symbol table structure, kept as a doubly linked list (stack). */
/* Symbol types are:
/*    int, real, int ary, real ary, unknown, untyped procedure or program. */
typedef struct SYM
  {
  char *block;           /* name of enclosing block */
  char *name;            /* name of this symbol */
  char type;             /* i,r,I,R,u,' ': codes for symbol types */
  int  start, end;       /* array bounds */
  int  offset;           /* location of this symbol */
  int  nparms;           /* number of formal parameters for funcs, procs */
  struct SYM  *parmlist; /* list of formal parameters (NULL for variables) */
  struct SYM  *next;     /* pointer to next symbol in the list */
  struct SYM  *last;     /* pointer to last symbol in the list */
  } SYM;

/* pointer tot he base of the entire symbol table */
SYM  *prog = NULL;

/* pointer to the symbol of the subprogram currently being parsed: */
SYM  *subprog = NULL;

/* current top of symbol stack */
SYM  *top  = NULL;

/* miscellaneous symbol variables */
SYM  *sym1 = NULL;
SYM  *sym2 = NULL;

/* counter for offset locations for variables */
int offset = 0;

/* A type for a list of strings: a pointer to this type may also be */
/* passed on the parse stack. */
typedef struct STR_LST
  {
  char *str1;
  struct STR_LST *next;
  } STR_LST;
STR_LST *lbl_stk = NULL;
STR_LST *list1, *list2;

int tv_cnt = 0;    /* temporary variable counter */
int lbl_cnt = 0;   /* label counter */
# define PGM 257
# define VAR 258
# define ARY 259
# define OF 260
# define INT 261
# define REAL 262
# define FUNC 263
# define PROC 264
# define BGN 265
# define END 266
# define IF 267
# define THEN 268
# define ELSE 269
# define WHILE 270
# define DO 271
# define NOT 272
# define DIV 273
# define MOD 274
# define AND 275
# define OR 276
# define ID 277
# define NUM 278
# define DD 279
# define ASGN 280
# define NE 281
# define LE 282
# define GE 283
# define LP 284
# define RP 285
# define SC 286
# define PE 287
# define CO 288
# define CL 289
# define LB 290
# define RB 291
# define PL 292
# define MI 293
# define EQ 294
# define LT 295
# define GT 296
# define MU 297
# define DI 298
# define UMIN 299

#include <malloc.h>
#include <memory.h>
#include <values.h>

#ifdef __cplusplus

#ifndef yyerror
	void yyerror(const char *);
#endif

#ifndef yylex
#ifdef __EXTERN_C__
	extern "C" { int yylex(void); }
#else
	int yylex(void);
#endif
#endif
	int yyparse(void);

#endif
#define yyclearin yychar = -1
#define yyerrok yyerrflag = 0
extern int yychar;
extern int yyerrflag;
#ifndef YYSTYPE
#define YYSTYPE int
#endif
YYSTYPE yylval;
YYSTYPE yyval;
typedef int yytabelem;
#ifndef YYMAXDEPTH
#define YYMAXDEPTH 150
#endif
#if YYMAXDEPTH > 0
int yy_yys[YYMAXDEPTH], *yys = yy_yys;
YYSTYPE yy_yyv[YYMAXDEPTH], *yyv = yy_yyv;
#else	/* user does initial allocation */
int *yys;
YYSTYPE *yyv;
#endif
static int yymaxdepth = YYMAXDEPTH;
# define YYERRCODE 256

# line 666 "proj1.yac"


#include "lex.yy.c"

/* Return an unique temporary variable.  Note that compiler generated */
/* labels start with upper case letters.  */
char *next_tv()
{
	char *s;
	s=(char *)malloc(10);
	if (s==NULL) 
	  {
	  printf("no room: next_tv (tv_cnt=%d)...\n",tv_cnt);
	  exit(1);
	  }
	sprintf(s,"T%d",tv_cnt++);
	return(s);
}

/* Return a unique label. */
char *next_lbl()
{
	char *s;
	s=(char *)malloc(10);
	if (s==NULL) 
	  {
	  printf("no room: next_lbl (lbl_cnt=%d)...\n",lbl_cnt);
	  exit(1);
	  }
	sprintf(s,"L%d",lbl_cnt++);
	return(s);
}
	
/* Save a character value (typically a label) on a stack. */
void push_lbl(c)
char *c;
{
	char *s;
	STR_LST *l;
	l=(STR_LST *)malloc(sizeof(STR_LST));
	if (l==NULL)
	  {
	  printf("no room: push_lbl (stack)\n");
	  exit(1);
	  }
	l->next=lbl_stk;
	l->str1=(char *)malloc(strlen(c)+1);
	if (l->str1==NULL)
 	  {
	  printf("no room: push_lbl (string)\n");
	  exit(1);
	  }
	strcpy(l->str1,c);
	lbl_stk=l;
}

/* retrieve a character value from the "label stack". */
char *pop_lbl()
{
	char *s;
	STR_LST *l;
	s=lbl_stk->str1;
	l=lbl_stk;
	lbl_stk=lbl_stk->next;
	free(l);
	return(s);
}
	
/***********  Symbol table routines **********/

/* Generate a new, blank symbol */
SYM *new_sym() 
{
	SYM *s;
	s=(SYM *)malloc(sizeof(SYM));
	s->block=NULL;
	s->name=NULL;
	s->type=' ';
	s->start=0;
	s->end=0;
	s->offset=0;
	s->nparms=0;
	s->parmlist=NULL;
	s->next=NULL;
	s->last=NULL;
	return(s);
}

/* Look for the symbol in the current context.  Return its pointer. */
SYM *find_sym(s)
char *s;
{
	SYM *f;
	int notfound;
	f=top;
	if (f!=NULL) notfound=strcmp(s,f->name);
	while (notfound && f!=NULL)
	  {
	  notfound=strcmp(s,f->name);
	  f=f->last;
	  }
	return(f);
}

/* Add a new symbol to the top of the symbol stack */
void add_sym(str,t)
char *str; /* name of new symbol */
char *t; /* type of symbol */
{
	SYM *s, *ss;

	ss=find_sym(str);
	if (ss!=NULL)
	  if (0==strcmp(ss->block,top->block))
	    {
	    printf("ERROR: duplicate declaration of name %s in block %s\n",
		ss->name, ss->block);
	    return;
	    }
	s=new_sym();
	s->block=strsave(top->block);
	top->next=s;
	s->last=top;
	top=s;
	top->name=str;
	if (t[0]=='i' || t[0]=='r') top->type=t[0];
	else
	  {
	  sscanf(t,"ary %d %d %c", &(top->start), &(top->end), &(top->type));
	  top->type -=32;  /* switch to upper case */
	  }
	top->offset=offset;
	offset = 4 * (top->end - top->start + 1) + offset;
	return;
}

/* Print the current symbol table. */
void print_sym(sub)
SYM *sub;
{
	SYM *s, *ss;
	int i;

	printf("*B %s\n",sub->block);
	s=top;
	while (s!=NULL)
	  {
	  if (s->parmlist==NULL)
	    {
	    printf("*V %s %s ",s->block,s->name);
	    if (s->type=='i') printf("integer ");
	    if (s->type=='r') printf("real ");
	    if (s->type=='I') printf("integer [%d..%d] ",s->start,s->end);
	    if (s->type=='R') printf("real [%d..%d] ",s->start,s->end);
	    if (s->type=='u') printf("unknown ");
	    printf("%d\n",s->offset);
	    }
	  else
	    {
	    if (s->type == ' ' && s->last!=NULL) printf("*R ");
	    else if (s->type==' ') printf("*P ");
	    else              printf("*F ");
	    printf("%s %s ",s->block,s->name);
	    if (s->type == 'i') printf("integer ");
	    else if (s->type == 'r') printf("real ");
	    printf("%d\n",s->nparms);
	    ss=s->parmlist;
	    if (ss->next!=s)
	      {
	      i=0;
	      while (i<s->nparms)
	        {
	        printf("*P%d ",++i);
	        if (ss->type=='i') printf("integer ");
	        if (ss->type=='r') printf("real ");
	        if (ss->type=='I') 
			printf("integer [%d..%d] ",ss->start,ss->end);
	        if (ss->type=='R') 
			printf("real [%d..%d] ",ss->start,ss->end);
	        if (ss->type=='u') printf("unknown ");
	        printf("%d\n",ss->offset);
	        ss=ss->next;
	        }
	      }
	    }
	  s=s->last;
	  }
}

/* Delete all of the symbols pointed to by s to the top of the stack. */ 
void free_sym_chain(s)
SYM *s;
{
	SYM *ss;
	while (s!=NULL)
	  {
	  free(s->block);
	  free(s->name);
	  ss=s->next;
	  free(s);
	  s=ss;
	  }
}

/* Parse error routine */
yyerror(s)
char *s;
{ printf("%s error at line no. %d \n",s,lineno);
}

main()
{
	yyparse();
}
yytabelem yyexca[] ={
-1, 1,
	0, -1,
	-2, 0,
-1, 59,
	290, 43,
	-2, 42,
	};
# define YYNPROD 73
# define YYLAST 239
yytabelem yyact[]={

    84,    87,    88,    89,   143,    77,    81,    79,   141,    62,
   101,    84,   120,    68,    59,    60,    82,    83,    76,    80,
    78,    61,     8,   142,     8,    85,    86,    82,    83,    56,
    55,    49,     8,   126,    96,    50,     8,    27,   134,   133,
   102,    48,   103,   103,   124,   125,    62,    28,    99,    67,
    47,    59,    60,    23,    11,   122,     9,    93,    61,    65,
     4,    22,   128,    37,   127,   137,    36,   100,     6,    26,
    25,    10,     3,    32,   130,   145,   105,    46,    22,    18,
    19,    43,     2,    44,    45,    44,    45,   147,    14,    31,
    42,    41,    73,     5,    57,    72,    53,    64,    92,    12,
    34,    58,   144,   140,    75,   104,    51,    54,    20,    35,
    33,    30,    29,    97,    40,    39,    21,    24,    38,    17,
    16,    15,    13,     7,     1,     0,     0,     0,     0,     0,
    52,     0,     0,     0,     0,     0,     0,    69,    66,    63,
     0,    70,    71,     0,    74,     0,     0,     0,     0,     0,
     0,     0,     0,     0,    94,     0,     0,    95,     0,    98,
     0,     0,     0,    90,    91,     0,     0,     0,     0,     0,
     0,     0,     0,   106,   107,   108,   109,   110,   111,     0,
   115,   116,   117,   118,   119,     0,     0,   123,     0,   121,
   112,   113,   114,     0,     0,   131,   129,     0,     0,     0,
     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
     0,     0,     0,   132,     0,     0,     0,     0,   136,   135,
   139,   138,     0,     0,     0,     0,     0,     0,     0,     0,
     0,     0,     0,     0,   146,   148,     0,     0,   149 };
yytabelem yypact[]={

  -175,-10000000,  -205,  -224,  -209,  -264,-10000000,  -229,  -206,  -232,
-10000000,-10000000,  -170,  -184,  -209,  -187,  -233,-10000000,  -207,  -208,
  -252,  -240,  -204,-10000000,  -170,-10000000,-10000000,  -178,-10000000,  -189,
  -236,-10000000,  -249,-10000000,-10000000,-10000000,-10000000,  -263,  -187,  -225,
  -225,  -237,-10000000,  -277,-10000000,-10000000,-10000000,  -204,  -263,  -263,
  -263,  -263,-10000000,  -276,  -272,  -226,  -226,-10000000,-10000000,  -227,
-10000000,  -263,  -226,-10000000,  -255,  -209,  -238,-10000000,  -211,-10000000,
  -281,-10000000,  -245,-10000000,-10000000,  -192,  -263,  -263,  -263,  -263,
  -263,  -263,  -226,  -226,  -226,  -226,  -226,  -226,  -226,  -226,
  -272,  -272,  -278,  -263,  -230,-10000000,  -176,  -241,  -256,-10000000,
  -215,  -218,-10000000,  -263,  -197,  -204,  -265,  -265,  -265,  -265,
  -265,  -265,  -272,  -272,  -272,-10000000,-10000000,-10000000,-10000000,-10000000,
  -263,  -246,-10000000,  -248,-10000000,  -209,  -178,  -213,  -263,-10000000,
  -204,-10000000,  -283,-10000000,-10000000,  -266,-10000000,  -287,-10000000,-10000000,
  -194,-10000000,  -178,  -173,-10000000,  -204,-10000000,  -176,-10000000,-10000000 };
yytabelem yypgo[]={

     0,   124,    93,   123,    99,   122,   121,   100,    91,    90,
   120,   119,   118,   115,    97,   114,   113,   112,   111,    89,
    92,   110,   109,   106,   105,   104,   103,   102,   101,    98,
    95,    96,   107,    94 };
yytabelem yyr1[]={

     0,     3,     6,     1,     2,     2,     4,     4,     8,     8,
     9,     9,     5,     5,    12,    10,    13,    11,    15,    11,
    14,    14,    16,    16,     7,    17,    17,    18,    18,    19,
    19,    19,    19,    19,    23,    24,    19,    25,    26,    22,
    27,    27,    28,    29,    28,    21,    21,    30,    30,    20,
    20,    20,    20,    20,    20,    20,    31,    31,    31,    31,
    31,    31,    32,    32,    32,    32,    32,    32,    33,    33,
    33,    33,    33 };
yytabelem yyr2[]={

     0,     1,     1,    25,     3,     7,     1,    13,     3,    17,
     3,     3,     0,     6,     1,     9,     1,    15,     1,    10,
     0,     7,     7,    11,     6,     0,     2,     2,     6,    13,
     7,     2,     2,     2,     1,     1,    13,     1,     1,    14,
     1,     5,     3,     1,    11,     3,     9,     3,     7,     2,
     7,     7,     7,     7,     7,     7,     2,     7,     7,     7,
     5,     5,     2,     7,     7,     7,     7,     7,     2,     9,
     3,     7,     5 };
yytabelem yychk[]={

-10000000,    -1,   257,   277,   284,    -2,   277,    -3,   288,   285,
   277,   286,    -4,    -5,   258,    -6,   -10,   -11,   263,   264,
    -2,    -7,   265,   286,    -4,   277,   277,   289,   287,   -17,
   -18,   -19,   277,   -21,    -7,   -22,   270,   267,   -12,   -13,
   -15,    -8,    -9,   259,   261,   262,   266,   286,   290,   280,
   284,   -23,   -20,   -31,   -32,   293,   292,   -33,   -28,   277,
   278,   284,   272,    -7,   -14,   284,   -14,   286,   290,   -19,
   -20,   -20,   -30,   -20,   -20,   -25,   294,   281,   296,   283,
   295,   282,   292,   293,   276,   297,   298,   273,   274,   275,
   -32,   -32,   -29,   284,   -20,   -33,   289,   -16,    -2,   286,
   278,   291,   285,   288,   -24,   268,   -31,   -31,   -31,   -31,
   -31,   -31,   -32,   -32,   -32,   -33,   -33,   -33,   -33,   -33,
   290,   -30,   285,    -9,   285,   286,   289,   279,   280,   -20,
   271,   -19,   -20,   285,   286,    -2,    -8,   278,   -20,   -19,
   -26,   291,   289,   291,   -27,   269,    -8,   260,   -19,    -9 };
yytabelem yydef[]={

     0,    -2,     0,     0,     0,     1,     4,     0,     0,     0,
     5,     6,    12,     2,     0,     0,     0,     6,     0,     0,
     0,     0,    25,    13,    14,    16,    18,     0,     3,     0,
    26,    27,    45,    31,    32,    33,    34,     0,     0,    20,
    20,     0,     8,     0,    10,    11,    24,     0,     0,     0,
     0,     0,    37,    49,    56,     0,     0,    62,    68,    -2,
    70,     0,     0,    15,     0,     0,     0,     7,     0,    28,
     0,    30,     0,    47,    35,     0,     0,     0,     0,     0,
     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
    60,    61,     0,     0,     0,    72,     0,     0,     0,    19,
     0,     0,    46,     0,     0,     0,    50,    51,    52,    53,
    54,    55,    57,    58,    59,    63,    64,    65,    66,    67,
     0,     0,    71,     0,    21,     0,     0,     0,     0,    48,
     0,    38,     0,    69,    17,     0,    22,     0,    29,    36,
    40,    44,     0,     0,    39,     0,    23,     0,    41,     9 };
typedef struct
#ifdef __cplusplus
	yytoktype
#endif
{ char *t_name; int t_val; } yytoktype;
#ifndef YYDEBUG
#	define YYDEBUG	0	/* don't allow debugging */
#endif

#if YYDEBUG

yytoktype yytoks[] =
{
	"PGM",	257,
	"VAR",	258,
	"ARY",	259,
	"OF",	260,
	"INT",	261,
	"REAL",	262,
	"FUNC",	263,
	"PROC",	264,
	"BGN",	265,
	"END",	266,
	"IF",	267,
	"THEN",	268,
	"ELSE",	269,
	"WHILE",	270,
	"DO",	271,
	"NOT",	272,
	"DIV",	273,
	"MOD",	274,
	"AND",	275,
	"OR",	276,
	"ID",	277,
	"NUM",	278,
	"DD",	279,
	"ASGN",	280,
	"NE",	281,
	"LE",	282,
	"GE",	283,
	"LP",	284,
	"RP",	285,
	"SC",	286,
	"PE",	287,
	"CO",	288,
	"CL",	289,
	"LB",	290,
	"RB",	291,
	"PL",	292,
	"MI",	293,
	"EQ",	294,
	"LT",	295,
	"GT",	296,
	"MU",	297,
	"DI",	298,
	"UMIN",	299,
	"-unknown-",	-1	/* ends search */
};

char * yyreds[] =
{
	"-no such reduction-",
	"prog : PGM ID LP idlist",
	"prog : PGM ID LP idlist RP SC decs spdecs",
	"prog : PGM ID LP idlist RP SC decs spdecs cpdstmt PE",
	"idlist : ID",
	"idlist : idlist CO ID",
	"decs : /* empty */",
	"decs : decs VAR idlist CL type SC",
	"type : stype",
	"type : ARY LB NUM DD NUM RB OF stype",
	"stype : INT",
	"stype : REAL",
	"spdecs : /* empty */",
	"spdecs : spdecs spdec SC",
	"spdec : sphead decs",
	"spdec : sphead decs cpdstmt",
	"sphead : FUNC ID",
	"sphead : FUNC ID args CL stype SC",
	"sphead : PROC ID",
	"sphead : PROC ID args SC",
	"args : /* empty */",
	"args : LP parlist RP",
	"parlist : idlist CL type",
	"parlist : parlist SC idlist CL type",
	"cpdstmt : BGN opstmt END",
	"opstmt : /* empty */",
	"opstmt : stmtlist",
	"stmtlist : stmt",
	"stmtlist : stmtlist SC stmt",
	"stmt : ID LB exp RB ASGN exp",
	"stmt : ID ASGN exp",
	"stmt : procstmt",
	"stmt : cpdstmt",
	"stmt : ifstmt",
	"stmt : WHILE",
	"stmt : WHILE exp",
	"stmt : WHILE exp DO stmt",
	"ifstmt : IF exp",
	"ifstmt : IF exp THEN stmt",
	"ifstmt : IF exp THEN stmt estmt",
	"estmt : /* empty */",
	"estmt : ELSE stmt",
	"var : ID",
	"var : ID",
	"var : ID LB exp RB",
	"procstmt : ID",
	"procstmt : ID LP explist RP",
	"explist : exp",
	"explist : explist CO exp",
	"exp : sexp",
	"exp : sexp EQ sexp",
	"exp : sexp NE sexp",
	"exp : sexp GT sexp",
	"exp : sexp GE sexp",
	"exp : sexp LT sexp",
	"exp : sexp LE sexp",
	"sexp : term",
	"sexp : sexp PL term",
	"sexp : sexp MI term",
	"sexp : sexp OR term",
	"sexp : MI term",
	"sexp : PL term",
	"term : factor",
	"term : term MU factor",
	"term : term DI factor",
	"term : term DIV factor",
	"term : term MOD factor",
	"term : term AND factor",
	"factor : var",
	"factor : ID LP explist RP",
	"factor : NUM",
	"factor : LP exp RP",
	"factor : NOT factor",
};
#endif /* YYDEBUG */
#if !defined(lint) && !defined(__cplusplus)
static  char __yaccpar_sccsid1[] = "@(#) 9/3/92 yaccpar 6.11 Copyr 1991 Sun Micro";
#endif

/*
** Skeleton parser driver for yacc output
*/

/*
** yacc user known macros and defines
*/
#define YYERROR		goto yyerrlab
#define YYACCEPT	return(0)
#define YYABORT		return(1)
#define YYBACKUP( newtoken, newvalue )\
{\
	if ( yychar >= 0 || ( yyr2[ yytmp ] >> 1 ) != 1 )\
	{\
		yyerror( "syntax error - cannot backup" );\
		goto yyerrlab;\
	}\
	yychar = newtoken;\
	yystate = *yyps;\
	yylval = newvalue;\
	goto yynewstate;\
}
#define YYRECOVERING()	(!!yyerrflag)
#define YYNEW(type)	malloc(sizeof(type) * yynewmax)
#define YYCOPY(to, from, type) \
	(type *) memcpy(to, (char *) from, yynewmax * sizeof(type))
#define YYENLARGE( from, type) \
	(type *) realloc((char *) from, yynewmax * sizeof(type))
#ifndef YYDEBUG
#	define YYDEBUG	1	/* make debugging available */
#endif

/*
** user known globals
*/
int yydebug;			/* set to 1 to get debugging */

/*
** driver internal defines
*/
#define YYFLAG		(-10000000)

/*
** global variables used by the parser
*/
YYSTYPE *yypv;			/* top of value stack */
int *yyps;			/* top of state stack */

int yystate;			/* current state */
int yytmp;			/* extra var (lasts between blocks) */

int yynerrs;			/* number of errors */
int yyerrflag;			/* error recovery flag */
int yychar;			/* current input token number */



#ifdef YYNMBCHARS
#define YYLEX()		yycvtok(yylex())
/*
** yycvtok - return a token if i is a wchar_t value that exceeds 255.
**	If i<255, i itself is the token.  If i>255 but the neither 
**	of the 30th or 31st bit is on, i is already a token.
*/
#if defined(__STDC__) || defined(__cplusplus)
int yycvtok(int i)
#else
int yycvtok(i) int i;
#endif
{
	int first = 0;
	int last = YYNMBCHARS - 1;
	int mid;
	wchar_t j;

	if(i&0x60000000){/*Must convert to a token. */
		if( yymbchars[last].character < i ){
			return i;/*Giving up*/
		}
		while ((last>=first)&&(first>=0)) {/*Binary search loop*/
			mid = (first+last)/2;
			j = yymbchars[mid].character;
			if( j==i ){/*Found*/ 
				return yymbchars[mid].tvalue;
			}else if( j<i ){
				first = mid + 1;
			}else{
				last = mid -1;
			}
		}
		/*No entry in the table.*/
		return i;/* Giving up.*/
	}else{/* i is already a token. */
		return i;
	}
}
#else/*!YYNMBCHARS*/
#define YYLEX()		yylex()
#endif/*!YYNMBCHARS*/

/*
** yyparse - return 0 if worked, 1 if syntax error not recovered from
*/
#if defined(__STDC__) || defined(__cplusplus)
int yyparse(void)
#else
int yyparse()
#endif
{
	register YYSTYPE *yypvt;	/* top of value stack for $vars */

#if defined(__cplusplus) || defined(lint)
/*
	hacks to please C++ and lint - goto's inside switch should never be
	executed; yypvt is set to 0 to avoid "used before set" warning.
*/
	static int __yaccpar_lint_hack__ = 0;
	switch (__yaccpar_lint_hack__)
	{
		case 1: goto yyerrlab;
		case 2: goto yynewstate;
	}
	yypvt = 0;
#endif

	/*
	** Initialize externals - yyparse may be called more than once
	*/
	yypv = &yyv[-1];
	yyps = &yys[-1];
	yystate = 0;
	yytmp = 0;
	yynerrs = 0;
	yyerrflag = 0;
	yychar = -1;

#if YYMAXDEPTH <= 0
	if (yymaxdepth <= 0)
	{
		if ((yymaxdepth = YYEXPAND(0)) <= 0)
		{
			yyerror("yacc initialization error");
			YYABORT;
		}
	}
#endif

	{
		register YYSTYPE *yy_pv;	/* top of value stack */
		register int *yy_ps;		/* top of state stack */
		register int yy_state;		/* current state */
		register int  yy_n;		/* internal state number info */
	goto yystack;	/* moved from 6 lines above to here to please C++ */

		/*
		** get globals into registers.
		** branch to here only if YYBACKUP was called.
		*/
	yynewstate:
		yy_pv = yypv;
		yy_ps = yyps;
		yy_state = yystate;
		goto yy_newstate;

		/*
		** get globals into registers.
		** either we just started, or we just finished a reduction
		*/
	yystack:
		yy_pv = yypv;
		yy_ps = yyps;
		yy_state = yystate;

		/*
		** top of for (;;) loop while no reductions done
		*/
	yy_stack:
		/*
		** put a state and value onto the stacks
		*/
#if YYDEBUG
		/*
		** if debugging, look up token value in list of value vs.
		** name pairs.  0 and negative (-1) are special values.
		** Note: linear search is used since time is not a real
		** consideration while debugging.
		*/
		if ( yydebug )
		{
			register int yy_i;

			printf( "State %d, token ", yy_state );
			if ( yychar == 0 )
				printf( "end-of-file\n" );
			else if ( yychar < 0 )
				printf( "-none-\n" );
			else
			{
				for ( yy_i = 0; yytoks[yy_i].t_val >= 0;
					yy_i++ )
				{
					if ( yytoks[yy_i].t_val == yychar )
						break;
				}
				printf( "%s\n", yytoks[yy_i].t_name );
			}
		}
#endif /* YYDEBUG */
		if ( ++yy_ps >= &yys[ yymaxdepth ] )	/* room on stack? */
		{
			/*
			** reallocate and recover.  Note that pointers
			** have to be reset, or bad things will happen
			*/
			int yyps_index = (yy_ps - yys);
			int yypv_index = (yy_pv - yyv);
			int yypvt_index = (yypvt - yyv);
			int yynewmax;
#ifdef YYEXPAND
			yynewmax = YYEXPAND(yymaxdepth);
#else
			yynewmax = 2 * yymaxdepth;	/* double table size */
			if (yymaxdepth == YYMAXDEPTH)	/* first time growth */
			{
				char *newyys = (char *)YYNEW(int);
				char *newyyv = (char *)YYNEW(YYSTYPE);
				if (newyys != 0 && newyyv != 0)
				{
					yys = YYCOPY(newyys, yys, int);
					yyv = YYCOPY(newyyv, yyv, YYSTYPE);
				}
				else
					yynewmax = 0;	/* failed */
			}
			else				/* not first time */
			{
				yys = YYENLARGE(yys, int);
				yyv = YYENLARGE(yyv, YYSTYPE);
				if (yys == 0 || yyv == 0)
					yynewmax = 0;	/* failed */
			}
#endif
			if (yynewmax <= yymaxdepth)	/* tables not expanded */
			{
				yyerror( "yacc stack overflow" );
				YYABORT;
			}
			yymaxdepth = yynewmax;

			yy_ps = yys + yyps_index;
			yy_pv = yyv + yypv_index;
			yypvt = yyv + yypvt_index;
		}
		*yy_ps = yy_state;
		*++yy_pv = yyval;

		/*
		** we have a new state - find out what to do
		*/
	yy_newstate:
		if ( ( yy_n = yypact[ yy_state ] ) <= YYFLAG )
			goto yydefault;		/* simple state */
#if YYDEBUG
		/*
		** if debugging, need to mark whether new token grabbed
		*/
		yytmp = yychar < 0;
#endif
		if ( ( yychar < 0 ) && ( ( yychar = YYLEX() ) < 0 ) )
			yychar = 0;		/* reached EOF */
#if YYDEBUG
		if ( yydebug && yytmp )
		{
			register int yy_i;

			printf( "Received token " );
			if ( yychar == 0 )
				printf( "end-of-file\n" );
			else if ( yychar < 0 )
				printf( "-none-\n" );
			else
			{
				for ( yy_i = 0; yytoks[yy_i].t_val >= 0;
					yy_i++ )
				{
					if ( yytoks[yy_i].t_val == yychar )
						break;
				}
				printf( "%s\n", yytoks[yy_i].t_name );
			}
		}
#endif /* YYDEBUG */
		if ( ( ( yy_n += yychar ) < 0 ) || ( yy_n >= YYLAST ) )
			goto yydefault;
		if ( yychk[ yy_n = yyact[ yy_n ] ] == yychar )	/*valid shift*/
		{
			yychar = -1;
			yyval = yylval;
			yy_state = yy_n;
			if ( yyerrflag > 0 )
				yyerrflag--;
			goto yy_stack;
		}

	yydefault:
		if ( ( yy_n = yydef[ yy_state ] ) == -2 )
		{
#if YYDEBUG
			yytmp = yychar < 0;
#endif
			if ( ( yychar < 0 ) && ( ( yychar = YYLEX() ) < 0 ) )
				yychar = 0;		/* reached EOF */
#if YYDEBUG
			if ( yydebug && yytmp )
			{
				register int yy_i;

				printf( "Received token " );
				if ( yychar == 0 )
					printf( "end-of-file\n" );
				else if ( yychar < 0 )
					printf( "-none-\n" );
				else
				{
					for ( yy_i = 0;
						yytoks[yy_i].t_val >= 0;
						yy_i++ )
					{
						if ( yytoks[yy_i].t_val
							== yychar )
						{
							break;
						}
					}
					printf( "%s\n", yytoks[yy_i].t_name );
				}
			}
#endif /* YYDEBUG */
			/*
			** look through exception table
			*/
			{
				register int *yyxi = yyexca;

				while ( ( *yyxi != -1 ) ||
					( yyxi[1] != yy_state ) )
				{
					yyxi += 2;
				}
				while ( ( *(yyxi += 2) >= 0 ) &&
					( *yyxi != yychar ) )
					;
				if ( ( yy_n = yyxi[1] ) < 0 )
					YYACCEPT;
			}
		}

		/*
		** check for syntax error
		*/
		if ( yy_n == 0 )	/* have an error */
		{
			/* no worry about speed here! */
			switch ( yyerrflag )
			{
			case 0:		/* new error */
				yyerror( "syntax error" );
				goto skip_init;
			yyerrlab:
				/*
				** get globals into registers.
				** we have a user generated syntax type error
				*/
				yy_pv = yypv;
				yy_ps = yyps;
				yy_state = yystate;
			skip_init:
				yynerrs++;
				/* FALLTHRU */
			case 1:
			case 2:		/* incompletely recovered error */
					/* try again... */
				yyerrflag = 3;
				/*
				** find state where "error" is a legal
				** shift action
				*/
				while ( yy_ps >= yys )
				{
					yy_n = yypact[ *yy_ps ] + YYERRCODE;
					if ( yy_n >= 0 && yy_n < YYLAST &&
						yychk[yyact[yy_n]] == YYERRCODE)					{
						/*
						** simulate shift of "error"
						*/
						yy_state = yyact[ yy_n ];
						goto yy_stack;
					}
					/*
					** current state has no shift on
					** "error", pop stack
					*/
#if YYDEBUG
#	define _POP_ "Error recovery pops state %d, uncovers state %d\n"
					if ( yydebug )
						printf( _POP_, *yy_ps,
							yy_ps[-1] );
#	undef _POP_
#endif
					yy_ps--;
					yy_pv--;
				}
				/*
				** there is no state on stack with "error" as
				** a valid shift.  give up.
				*/
				YYABORT;
			case 3:		/* no shift yet; eat a token */
#if YYDEBUG
				/*
				** if debugging, look up token in list of
				** pairs.  0 and negative shouldn't occur,
				** but since timing doesn't matter when
				** debugging, it doesn't hurt to leave the
				** tests here.
				*/
				if ( yydebug )
				{
					register int yy_i;

					printf( "Error recovery discards " );
					if ( yychar == 0 )
						printf( "token end-of-file\n" );
					else if ( yychar < 0 )
						printf( "token -none-\n" );
					else
					{
						for ( yy_i = 0;
							yytoks[yy_i].t_val >= 0;
							yy_i++ )
						{
							if ( yytoks[yy_i].t_val
								== yychar )
							{
								break;
							}
						}
						printf( "token %s\n",
							yytoks[yy_i].t_name );
					}
				}
#endif /* YYDEBUG */
				if ( yychar == 0 )	/* reached EOF. quit */
					YYABORT;
				yychar = -1;
				goto yy_newstate;
			}
		}/* end if ( yy_n == 0 ) */
		/*
		** reduction by production yy_n
		** put stack tops, etc. so things right after switch
		*/
#if YYDEBUG
		/*
		** if debugging, print the string that is the user's
		** specification of the reduction which is just about
		** to be done.
		*/
		if ( yydebug )
			printf( "Reduce by (%d) \"%s\"\n",
				yy_n, yyreds[ yy_n ] );
#endif
		yytmp = yy_n;			/* value to switch over */
		yypvt = yy_pv;			/* $vars top of value stack */
		/*
		** Look in goto table for next state
		** Sorry about using yy_state here as temporary
		** register variable, but why not, if it works...
		** If yyr2[ yy_n ] doesn't have the low order bit
		** set, then there is no action to be done for
		** this reduction.  So, no saving & unsaving of
		** registers done.  The only difference between the
		** code just after the if and the body of the if is
		** the goto yy_stack in the body.  This way the test
		** can be made before the choice of what to do is needed.
		*/
		{
			/* length of production doubled with extra bit */
			register int yy_len = yyr2[ yy_n ];

			if ( !( yy_len & 01 ) )
			{
				yy_len >>= 1;
				yyval = ( yy_pv -= yy_len )[1];	/* $$ = $1 */
				yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] +
					*( yy_ps -= yy_len ) + 1;
				if ( yy_state >= YYLAST ||
					yychk[ yy_state =
					yyact[ yy_state ] ] != -yy_n )
				{
					yy_state = yyact[ yypgo[ yy_n ] ];
				}
				goto yy_stack;
			}
			yy_len >>= 1;
			yyval = ( yy_pv -= yy_len )[1];	/* $$ = $1 */
			yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] +
				*( yy_ps -= yy_len ) + 1;
			if ( yy_state >= YYLAST ||
				yychk[ yy_state = yyact[ yy_state ] ] != -yy_n )
			{
				yy_state = yyact[ yypgo[ yy_n ] ];
			}
		}
					/* save until reenter driver code */
		yystate = yy_state;
		yyps = yy_ps;
		yypv = yy_pv;
	}
	/*
	** code supplied by user is placed in this switch
	*/
	switch( yytmp )
	{
		
case 1:
# line 74 "proj1.yac"
{
		/* generate the program symbol (bottom of the stack) */
			prog = new_sym();
			top = prog;
			top->block=strsave(yypvt[-2]);
			top->name=strsave(yypvt[-2]);
			top->parmlist=top;
		/* process STR_LST structure returned from idlist */
		/* add parameters returned from idlist to sym. table */
		/* 1st: transform the circular list to a linear list */
			list1=((STR_LST *)yypvt[-0])->next;
			((STR_LST *)yypvt[-0])->next=NULL;
			while (list1!=NULL)
			  {
			  sym1 = new_sym();
			  if (top->parmlist==top) top->parmlist=sym1;
			  top->next = sym1;
			  sym1->last = top;
			  top=sym1;
			  top->block = strsave(prog->block);
			  top->name = list1->str1;
			  top->type = 'u';
			  prog->nparms++;
			  list2=list1;
			  list1=list2->next;
			  free(list2);
			  }
			} break;
case 2:
# line 103 "proj1.yac"
{
		/* All symbols have been collected for the program. */
		/* Report them now. */
			print_sym(prog);
			PRINT_QUAD("_start","NOP","","","");
			} break;
case 3:
# line 110 "proj1.yac"
{
			PRINT_QUAD("","CALL","","","_exit");
			} break;
case 4:
# line 119 "proj1.yac"
{
			list1=(STR_LST *)malloc(sizeof(STR_LST));
			list1->str1 = yypvt[-0];
			list1->next = list1;
			yyval = list1;
			} break;
case 5:
# line 126 "proj1.yac"
{
			list1=(STR_LST *)malloc(sizeof(STR_LST));
			list1->str1=yypvt[-0];
			list1->next=((STR_LST *)yypvt[-2])->next;
			((STR_LST *)yypvt[-2])->next=list1;
			yyval=list1;
			} break;
case 6:
# line 138 "proj1.yac"
{yyval = NULL;} break;
case 7:
# line 140 "proj1.yac"
{
		/* 1st: transform the circular list into a linear linked list */
			list1=((STR_LST *)yypvt[-3])->next;
			((STR_LST *)yypvt[-3])->next=NULL;
			while (list1!=NULL)
			  {
			  add_sym(list1->str1,yypvt[-1]);
			  list2=list1;
			  list1=list2->next;
			  free(list2);
			  }
			} break;
case 8:
# line 156 "proj1.yac"
{ yyval=yypvt[-0]; } break;
case 9:
# line 158 "proj1.yac"
{
			yyval=(void *)malloc(strlen("ary ")+strlen(yypvt[-5])+strlen(yypvt[-3])+
					  strlen(yypvt[-0])+10);
			strcpy(yyval,"ary ");
			strcat(yyval,yypvt[-5]);
			strcat(yyval," ");
			strcat(yyval,yypvt[-3]);
			strcat(yyval," ");
			strcat(yyval,yypvt[-0]);
			} break;
case 10:
# line 172 "proj1.yac"
{
			yyval=(char *)malloc(4);
			strcpy(yyval,"int");
			} break;
case 11:
# line 177 "proj1.yac"
{
			yyval=(char *)malloc(5);
			strcpy(yyval,"real");
			} break;
case 14:
# line 188 "proj1.yac"
{
		/* print out the subprogram's symbol table */
			print_sym(subprog);
		/*
			temp=next_lbl();
			printf("*\n*entry point is %s\n",temp);
			PRINT_QUAD(temp,"NOP","","","");
		*/
			PRINT_QUAD(subprog->name,"NOP","","","");
			} break;
case 15:
# line 199 "proj1.yac"
{
			int i;
		/* End the subroutine with a return statement */
			PRINT_QUAD("","RTN","","","");
		/* Adjust symbol table so the next subroutine or the */
		/* main program can be parsed next.  Drop local variables */
		/* while keeping parameter data. */
			top=subprog;
			for (i=0; i<top->nparms; i++)
			  {
			  subprog=subprog->next;
			  }
			sym1=subprog->next;
			top->next=NULL;
			subprog->next=NULL;
			free_sym_chain(sym1);
			} break;
case 16:
# line 219 "proj1.yac"
{
		/* Set up a new symbol for the function.  Update the */
		/* subprogram symbol pointer. */
			subprog=new_sym();
			top->next=subprog;
			subprog->last=top;
			top=subprog;
			top->block=strsave(yypvt[-0]);
			top->name=strsave(yypvt[-0]);
			top->offset=offset;
			top->parmlist=top;
			} break;
case 17:
# line 232 "proj1.yac"
{
		/* Set up the return value type for the subprogram. */
			subprog->type=((char *)yypvt[-1])[0];
			} break;
case 18:
# line 237 "proj1.yac"
{
		/* Set up a new symbol for the procedure.  Update the */
		/* subprogram symbol pointer. */
			subprog=new_sym();
			top->next=subprog;
			subprog->last=top;
			top=subprog;
			top->block=strsave(yypvt[-0]);
			top->name=strsave(yypvt[-0]);
			top->offset=offset;
		/* Make the parmlist not NULL.  One way procedures and */
		/* functions are distinguished from other symbols is that */
		/* the parmlist pointer is not NULL, even though there may */
		/* may be no parmeter list. */
			top->parmlist=top;
			} break;
case 21:
# line 258 "proj1.yac"
{
			yyval=yypvt[-1];
			} break;
case 22:
# line 264 "proj1.yac"
{
		/* Process the identifier list.  Make symbols for the */
		/* parameters, linking them to both the stack top and */
		/* the subprogram parameter list. */
			list1=((STR_LST *)yypvt[-2])->next;
			((STR_LST *)yypvt[-2])->next=NULL;
			while (list1!=NULL)
			  {
			  add_sym(list1->str1,yypvt[-0]);
			  subprog->nparms++;
			  list2=list1;
			  list1=list1->next;
			  free(list2);
			  }
		/* This will be the first parameter in the list.  Set up */
		/* the parameter pointer to this parameter. */
			subprog->parmlist=subprog->next;
			yyval=NULL;
			} break;
case 23:
# line 284 "proj1.yac"
{
		/* Process the identifier list.  Make symbols for the */
		/* parameters, linking them to both the stack top and */
		/* the subprogram parameter list. */
			list1=((STR_LST *)yypvt[-2])->next;
			((STR_LST *)yypvt[-2])->next=NULL;
			while (list1!=NULL)
			  {
			  add_sym(list1->str1,yypvt[-0]);
			  subprog->nparms++;
			  list2=list1;
			  list1=list1->next;
			  free(list2);
			  }
			yyval=NULL;
			} break;
case 29:
# line 314 "proj1.yac"
{
		/* Assignment to an array element. */
			PRINT_QUAD("","[]=",yypvt[-5],yypvt[-3],yypvt[-0]);
			} break;
case 30:
# line 319 "proj1.yac"
{
		/* Assignment to a scalar. */
			PRINT_QUAD("","MOV",yypvt[-0],"",yypvt[-2]);
			} break;
case 34:
# line 327 "proj1.yac"
{
		/* Label loop top and stack the label on the label stack. */
			temp=next_lbl();
			push_lbl(temp);
			PRINT_QUAD(temp,"NOP","","","");
			} break;
case 35:
# line 334 "proj1.yac"
{
		/* Check for end of loop.  Stack the branch label. */
			temp=next_lbl();
			push_lbl(temp);
			PRINT_QUAD("","JZ",yypvt[-0],"",temp);
			} break;
case 36:
# line 341 "proj1.yac"
{
		/* Pop the 2 saved labels.  Unconditional jump to the */
		/* 1st label, label a NOP statement with the second. */
			temp1=pop_lbl();
			temp2=pop_lbl();
			PRINT_QUAD("","JMP","","",temp2);
			PRINT_QUAD(temp1,"NOP","","","");
			free(temp1);
			free(temp2);
			} break;
case 37:
# line 354 "proj1.yac"
{
		/* Handle labels for the ifstmt */
			temp=next_lbl();
			push_lbl(temp);
			PRINT_QUAD("","JZ",yypvt[-0],"",temp);
			} break;
case 38:
# line 361 "proj1.yac"
{
			temp1=next_lbl();
			PRINT_QUAD("","JMP","","",temp1);
			temp=pop_lbl();
			PRINT_QUAD(temp,"NOP","","","");
			push_lbl(temp1);
			free(temp);
			} break;
case 40:
# line 373 "proj1.yac"
{
		/* Handle lables for if without else. */
			temp=pop_lbl();
			PRINT_QUAD(temp,"NOP","","","");
			free(temp);
			} break;
case 41:
# line 380 "proj1.yac"
{
		/* Handle labels for if with else. */
			temp=pop_lbl();
			PRINT_QUAD(temp,"NOP","","","");
			free(temp);
			} break;
case 42:
# line 388 "proj1.yac"
{
		/* Parser stack the value of the identifier returned by Lex */
			yyval=(void *)malloc(strlen(yylval)+1);
			strcpy(yyval,yylval);
			} break;
case 43:
# line 394 "proj1.yac"
{
		/* Save identifier of an array on the label stack */
			push_lbl(yylval);
			} break;
case 44:
# line 399 "proj1.yac"
{
		/* Make a temporary variable equal to the evaluation of the */
		/* array reference. */
			temp=pop_lbl();
			temp1=next_tv();
			PRINT_QUAD("","[]",temp,yypvt[-1],temp1);
			yyval=temp1;
			free(temp);
			} break;
case 45:
# line 411 "proj1.yac"
{
		/* Call the procedure */
			PRINT_QUAD("","CALL","","",yypvt[-0]);
			} break;
case 46:
# line 416 "proj1.yac"
{
		/* "PUSH" variables before calling procedure */
			list1=((STR_LST *)yypvt[-1])->next;
			((STR_LST *)yypvt[-1])->next=NULL;
			while (list1!=NULL)
			  {
			  PRINT_QUAD("","PUSH","","",list1->str1);
			  list2=list1->next;
			  free(list1);
			  list1=list2;
			  }
			PRINT_QUAD("","CALL","","",yypvt[-3]);
			} break;
case 47:
# line 432 "proj1.yac"
{
		/* Start building a circular list of expressions for passing */
			list1=(STR_LST *)malloc(sizeof(STR_LST));
			list1->str1 = yypvt[-0];
			list1->next = list1;
			yyval = list1;
			} break;
case 48:
# line 440 "proj1.yac"
{
		/* Add to the circular list of expressions for parm passing */
			list1=(STR_LST *)malloc(sizeof(STR_LST));
			list1->str1=yypvt[-0];
			list1->next=((STR_LST *)yypvt[-2])->next;
			((STR_LST *)yypvt[-2])->next=list1;
			yyval=list1;
			} break;
case 50:
# line 452 "proj1.yac"
{
		/* Expand the '=' operation with our set of quad operations */
			temp=next_lbl();
			temp1=next_tv();
			temp2=next_tv();
			PRINT_QUAD("","MOV","1","",temp1);
			PRINT_QUAD("","SUB",yypvt[-2],yypvt[-0],temp2);
			PRINT_QUAD("","JZ",temp2,"",temp);
			PRINT_QUAD("","MOV","0","",temp1);
			PRINT_QUAD(temp,"NOP","","","");
			yyval = temp1;
			free(temp);
			free(temp2);
			} break;
case 51:
# line 467 "proj1.yac"
{
		/* Expand the '<>' operation with our set of quad operations */
			temp1=next_tv();
			temp2=next_tv();
			temp=next_lbl();
			PRINT_QUAD("","MOV","0","",temp1);
			PRINT_QUAD("","SUB",yypvt[-2],yypvt[-0],temp2);
			PRINT_QUAD("","JZ",temp2,"",temp);
			PRINT_QUAD("","MOV","1","",temp1);
			PRINT_QUAD(temp,"NOP","","","");
			yyval = temp1;
			free(temp);
			free(temp2);
			} break;
case 52:
# line 482 "proj1.yac"
{
		/* Expand the '>' operation with our set of quad operations */
			temp1=next_tv();
			temp2=next_tv();
			temp=next_lbl();
			PRINT_QUAD("","MOV","1","",temp1);
			PRINT_QUAD("","SUB",yypvt[-2],yypvt[-0],temp2);
			PRINT_QUAD("","JGZ",temp2,"",temp);
			PRINT_QUAD("","MOV","0","",temp1);
			PRINT_QUAD(temp,"NOP","","","");
			yyval = temp1;
			free(temp);
			free(temp2);
			} break;
case 53:
# line 497 "proj1.yac"
{
		/* Expand the '>=' operation with our set of quad operations */
			temp1=next_tv();
			temp2=next_tv();
			temp=next_lbl();
			PRINT_QUAD("","MOV","0","",temp1);
			PRINT_QUAD("","SUB",yypvt[-0],yypvt[-2],temp2);
			PRINT_QUAD("","JGZ",temp2,"",temp);
			PRINT_QUAD("","MOV","1","",temp1);
			PRINT_QUAD(temp,"NOP","","","");
			yyval = temp1;
			free(temp);
			free(temp2);
			} break;
case 54:
# line 512 "proj1.yac"
{
		/* Expand the '<' operation with our set of quad operations */
			temp1=next_tv();
			temp2=next_tv();
			temp=next_lbl();
			PRINT_QUAD("","MOV","1","",temp1);
			PRINT_QUAD("","SUB",yypvt[-0],yypvt[-2],temp2);
			PRINT_QUAD("","JGZ",temp2,"",temp);
			PRINT_QUAD("","MOV","0","",temp1);
			PRINT_QUAD(temp,"NOP","","","");
			yyval = temp1;
			free(temp);
			free(temp2);
			} break;
case 55:
# line 527 "proj1.yac"
{
		/* Expand the '<=' operation with our set of quad operations */
			temp1=next_tv();
			temp2=next_tv();
			temp=next_lbl();
			PRINT_QUAD("","MOV","0","",temp1);
			PRINT_QUAD("","SUB",yypvt[-2],yypvt[-0],temp2);
			PRINT_QUAD("","JGZ",temp2,"",temp);
			PRINT_QUAD("","MOV","1","",temp1);
			PRINT_QUAD(temp,"NOP","","","");
			yyval = temp1;
			free(temp);
			free(temp2);
			} break;
case 57:
# line 545 "proj1.yac"
{
			temp=next_tv();
			PRINT_QUAD("","ADD",yypvt[-2],yypvt[-0],temp);
			yyval = temp;
			} break;
case 58:
# line 551 "proj1.yac"
{
			temp=next_tv();
			PRINT_QUAD("","SUB",yypvt[-2],yypvt[-0],temp);
			yyval = temp;
			} break;
case 59:
# line 557 "proj1.yac"
{
		/* Expand the 'or' operation with our set of quad operations */
			temp=next_tv();
			temp1=next_lbl();
			temp2=next_lbl();
			PRINT_QUAD("","MOV","0","",temp);
			PRINT_QUAD("","JZ",yypvt[-2],"",temp1);
			PRINT_QUAD("","MOV","1","",temp);
			PRINT_QUAD(temp1,"JZ",yypvt[-0],"",temp2);
			PRINT_QUAD("","MOV","1","",temp);
			PRINT_QUAD(temp2,"NOP","","","");
			yyval = temp;
			free(temp1);
			free(temp2);
			} break;
case 60:
# line 573 "proj1.yac"
{
		/* Expand unary minus with our set of quad operations */
			temp=next_tv();
			PRINT_QUAD("","SUB","0",yypvt[-0],yypvt[-0]);
			yyval=yypvt[-0];
			} break;
case 61:
# line 580 "proj1.yac"
{
			yyval = yypvt[-0];
			} break;
case 63:
# line 587 "proj1.yac"
{
			temp=next_tv();
			PRINT_QUAD("","MUL",yypvt[-2],yypvt[-0],temp);
			yyval = temp;
			} break;
case 64:
# line 593 "proj1.yac"
{
			temp=next_tv();
			PRINT_QUAD("","DI",yypvt[-2],yypvt[-0],temp);
			yyval = temp;
			} break;
case 65:
# line 599 "proj1.yac"
{
			temp=next_tv();
			PRINT_QUAD("","DIV",yypvt[-2],yypvt[-0],temp);
			yyval = temp;
			} break;
case 66:
# line 605 "proj1.yac"
{
			temp=next_tv();
			PRINT_QUAD("","MOD",yypvt[-2],yypvt[-0],temp);
			yyval = temp;
			} break;
case 67:
# line 611 "proj1.yac"
{ 
		/* Expand the 'and' operation with our set of quad operations */
			temp=next_tv();
			temp1=next_lbl();
			PRINT_QUAD("","MOV","0","",temp);
			PRINT_QUAD("","JZ",yypvt[-2],"",temp1);
			PRINT_QUAD("","JZ",yypvt[-0],"",temp1);
			PRINT_QUAD("","MOV","1","",temp);
			PRINT_QUAD(temp1,"NOP","","","");
			yyval = temp;
			} break;
case 69:
# line 626 "proj1.yac"
{
		/* Convert circular list of expressions to a linear list */
		/* Write "PUSH" commands to send the expressions, the */
		/* CALL command to call the subroutine, and the PULL */
		/* command to return the value */
			list1=((STR_LST *)yypvt[-1])->next;
			((STR_LST *)yypvt[-1])->next=NULL;
			while (list1!=NULL)
			  {
			  PRINT_QUAD("","PUSH","","",list1->str1);
			  list2=list1->next;
			  free(list1);
			  list1=list2;
			  }
			PRINT_QUAD("","CALL","","",yypvt[-3]);
			temp1=next_tv();
			PRINT_QUAD("","PULL","","",temp1);
			yyval=temp1;
			} break;
case 70:
# line 646 "proj1.yac"
{
		yyval=(char *)malloc(strlen(yylval)+1);
		strcpy(yyval,yylval);
		} break;
case 71:
# line 651 "proj1.yac"
{
		yyval = yypvt[-1];
		} break;
case 72:
# line 655 "proj1.yac"
{
		/* Expand the 'not' operation with our set of quad operations */
		temp=next_lbl();
		temp1=next_tv();
		PRINT_QUAD("","MOV","1","",temp1);
		PRINT_QUAD("","JZ",yypvt[-0],"",temp);
		PRINT_QUAD("","MOV","0","",temp1);
		PRINT_QUAD(temp,"NOP","","","");
		free(temp);
		} break;
	}
	goto yystack;		/* reset registers in driver code */
}

