# include "rag.hh"
# include "nodes.h"
# include "grc.h"

IAT* grnl= NULL;

# include "swbus.h"

PRIVATE void
PROCESINI (r)
    TNODE* r;
{
  TNODE* h[33];
  /* KJT 20/01/23: added "int" type */
  register int i;
  int nr;
  int* grl;

  while (r != NULL) {
    h[0]= r;
    heval (r, h);
    grl= grnl->data[(int)(r->value0)];
    for (i= 0; grl[i] != 0; i++) {
     nr= grl[i];
     switch (nr) {
      case _specification_1:
	 if (h[0] != NULL)
	  adclr (-c_dec, h[0], 1);
	 break;
      case _sort_pair_1:
	 adclr (-c_isname, h[1], 2);
	 adclr (-c_isname, h[2], 3);
	 break;
      case _operation_pair_1:
	 adclr (-c_isname, h[1], 4);
	 adclr (-c_isname, h[2], 5);
	 break;
      case _formal_sorts_1:
	 h[3]= h[1];
	 h[4]= gt_rb (h[3]);
	 while (h[3] != NULL) {
	  adclr (-c_isname, h[3], 6);
	  h[3]= h[4];
	  h[4]= gt_rb (h[4]);
	 }
	 break;
      case _sort_id_comm_1:
	 if (h[1] != NULL)
	  adclr (-c_isname, h[1], 7);
	 break;
      case _operation_1:
	 if (h[3] != NULL)
	  adclr (-c_isname, h[3], 8);
	 if (h[1] != NULL)
	  adclr (-c_legend, h[1], 9);
	 break;
      case _descriptor_list_1:
	 h[3]= h[1];
	 h[4]= gt_rb (h[3]);
	 while (h[3] != NULL) {
	  adclr (-c_legend, h[3], 10);
	  h[3]= h[4];
	  h[4]= gt_rb (h[4]);
	 }
	 break;
      case _operation_descriptor_1:
	 if (h[1] != NULL)
	  adclr (-c_isname, h[1], 11);
	 if (h[1] != NULL)
	  adclr (-c_legend, h[1], 12);
	 break;
      case _operation_descriptor_2:
	 if (h[1] != NULL)
	  adclr (-c_isname, h[1], 13);
	 if (h[1] != NULL)
	  adclr (-c_legend, h[1], 14);
	 break;
      case _argument_list_1:
	 h[3]= h[1];
	 h[4]= gt_rb (h[3]);
	 while (h[3] != NULL) {
	  adclr (-c_isname, h[3], 15);
	  h[3]= h[4];
	  h[4]= gt_rb (h[4]);
	 }
	 if (h[1] != NULL)
	  adclr (-c_legend, h[1], 16);
	 h[3]= h[1];
	 h[4]= gt_rb (h[3]);
	 while (h[4] != NULL) {
	  adclr (-c_legend, h[4], 17);
	  h[3]= h[4];
	  h[4]= gt_rb (h[4]);
	 }
	 if (h[0] != NULL)
	  adclr (-c_legend, h[0], 18);
	 break;
      case _equation_list_1:
	 if (h[1] != NULL)
	  adclr (-c_isname, h[1], 19);
	 break;
      case _process_definition_1:
	 adclr (-c_dec, h[0], 20);
	 break;
      case _formal_parameter_list_1:
	 if (h[0] != NULL)
	  adclr (-c_legend, h[0], 21);
	 break;
      case _gate_parameter_list_1:
	 if (h[0] != NULL)
	  adclr (-c_legend, h[0], 22);
	 break;
      case _value_parameter_list_1:
	 adclr (-c_legend, h[0], 23);
	 break;
      case _functionality_list_1:
	 if (h[0] != NULL)
	  adclr (-c_legend, h[0], 24);
	 break;
      case _functionality_list_2:
	 adclr (-c_legend, h[0], 25);
	 break;
      case _exit_list_1:
	 h[3]= h[1];
	 h[4]= gt_rb (h[3]);
	 while (h[3] != NULL) {
	  adclr (-c_isname, h[3], 26);
	  h[3]= h[4];
	  h[4]= gt_rb (h[4]);
	 }
	 if (h[1] != NULL)
	  adclr (-c_legend, h[1], 27);
	 h[3]= h[1];
	 h[4]= gt_rb (h[3]);
	 while (h[4] != NULL) {
	  adclr (-c_legend, h[4], 28);
	  h[3]= h[4];
	  h[4]= gt_rb (h[4]);
	 }
	 if (h[0] != NULL)
	  adclr (-c_legend, h[0], 29);
	 break;
      case _experiment_offer_1:
	 adclr (-c_isname, h[2], 30);
	 adclr (-c_sname, h[1], 31);
	 adclr (-c_gateoval, h[1], 32);
	 break;
      case exit_entry_2:
	 adclr (-c_isname, h[1], 33);
	 break;
      case _process_instantiation_1:
	 if (h[0] != NULL)
	  adclr (-c_dec, h[0], 34);
	 break;
      case _value_expression_1:
	 if (h[0] != NULL)
	  adclr (-c_dec, h[0], 35);
	 break;
      case _identifier_declarations_1:
	 if (h[1] != NULL)
	  adclr (-c_aux_legend, h[1], 36);
	 h[3]= h[1];
	 h[4]= gt_rb (h[3]);
	 while (h[4] != NULL) {
	  adclr (-c_aux_legend, h[4], 37);
	  h[3]= h[4];
	  h[4]= gt_rb (h[4]);
	 }
	 if (h[0] != NULL)
	  adclr (-c_legend, h[0], 38);
	 break;
      case _identifier_declaration_1:
	 adclr (-c_isname, h[2], 39);
	 adclr (-c_gateoval, h[1], 40);
	 adclr (-c_sname, h[1], 41);
	 adclr (-c_legend, h[0], 42);
	 break;
      case _gate_declaration_list_1:
	 if (h[1] != NULL)
	  adclr (-c_legend, h[1], 43);
	 h[3]= h[1];
	 h[4]= gt_rb (h[3]);
	 while (h[4] != NULL) {
	  adclr (-c_legend, h[4], 44);
	  h[3]= h[4];
	  h[4]= gt_rb (h[4]);
	 }
	 if (h[0] != NULL)
	  adclr (-c_legend, h[0], 45);
	 break;
      case _gate_declaration_1:
	 if (h[1] != NULL)
	  adclr (-c_gateoval, h[1], 46);
	 break;
      case _identifier_declaration_list_1:
	 h[3]= h[1];
	 h[4]= gt_rb (h[3]);
	 while (h[3] != NULL) {
	  adclr (-c_gateoval, h[3], 47);
	  h[3]= h[4];
	  h[4]= gt_rb (h[4]);
	 }
	 h[3]= h[1];
	 h[4]= gt_rb (h[3]);
	 while (h[3] != NULL) {
	  adclr (-c_legend, h[3], 48);
	  h[3]= h[4];
	  h[4]= gt_rb (h[4]);
	 }
	 if (h[1] != NULL)
	  adclr (-c_aux_legend, h[1], 49);
	 h[3]= h[1];
	 h[4]= gt_rb (h[3]);
	 while (h[4] != NULL) {
	  adclr (-c_aux_legend, h[4], 50);
	  h[3]= h[4];
	  h[4]= gt_rb (h[4]);
	 }
	 if (h[0] != NULL)
	  adclr (-c_legend, h[0], 51);
	 break;
      case _type_identifier_1:
	 adclr (-c_dec, h[0], 52);
	 break;
      case _sort_identifier_1:
	 adclr (-c_dec, h[0], 53);
	 break;
      case _operation_identifier_1:
	 adclr (-c_dec, h[0], 54);
	 break;
      case _operation_identifier_2:
	 adclr (-c_dec, h[0], 55);
	 break;
      case _gate_identifier_1:
	 adclr (-c_dec, h[0], 56);
	 break;
      case _identifier_1:
	 if (h[0] != NULL)
	  adclr (-c_dec, h[0], 57);
	 break;
      default:
	 assert ((1 <= nr) && (nr <= LAST_RULE));
      }
    } /* end of while (ngr != NULL) */
    r= succ (r, PREORDER);
  } /* end of while (r != NULL) */
} /* end of PROCESINI */

PUBLIC CLR_TYPE
eval (nar, r)
    int nar;
    TNODE* r;
{
  TNODE* h[33];

  if (r == NULL) return (CLR_TYPE)NULL;
  switch (nar) {
  case 1:
    h[0]= r;
    heval (h[0], h);

     if (find_attr (c_iddec, h[1]) != NULL)
	return (CLR_TYPE) putid (mygetlexv ((TNODE*)h[1]),
		     TSPEC,
		     (int)fdclr (c_iddec,h[1], nar),
		     c_iddec,
		     *(int*)fdclr (c_line,h[1], nar),
		     (INTlist)fdclr (c_legend,h[2], nar));
     else  return (CLR_TYPE) putid ((int)fdclr (c_lexv,h[1], nar),
			TSPEC,
			0,
			c_idref,
			*(int*)fdclr (c_line,h[1], nar),
			(INTlist)fdclr (c_legend,h[2], nar));
  case 2:
    h[0]= gt_ft (r);
    heval (h[0], h);
   return (CLR_TYPE) TRUE;
  case 3:
    h[0]= gt_ft (r);
    heval (h[0], h);
   return (CLR_TYPE) TRUE;
  case 4:
    h[0]= gt_ft (r);
    heval (h[0], h);
   return (CLR_TYPE) TRUE;
  case 5:
    h[0]= gt_ft (r);
    heval (h[0], h);
   return (CLR_TYPE) TRUE;
  case 6:
    h[0]= gt_ft (r);
    h[1]= gt_fs (h[0]);
    h[3]= r;
    h[4]= gt_rb (h[3]);
    h[5]= gt_ls (h[0]);
   return (CLR_TYPE) FALSE;
  case 7:
    h[0]= gt_ft (r);
    heval (h[0], h);
   return (CLR_TYPE) FALSE;
  case 8:
    h[0]= gt_ft (r);
    heval (h[0], h);
   return (CLR_TYPE) FALSE;
  case 9:
    h[0]= gt_ft (r);
    heval (h[0], h);

     if (h[2] == NULL)
	return (CLR_TYPE)
	 INT2cons (LEFT_ARROW, mygetlexv ((TNODE*)h[3]),
		   (INTlist)NULL);
     else
	return (CLR_TYPE) INTrev (INT2cons (mygetlexv ((TNODE*)h[3]),
			       LEFT_ARROW, (INTlist)fdclr (c_legend,h[2], nar)));
  case 10:
    h[0]= gt_ft (r);
    h[1]= gt_fs (h[0]);
    h[3]= r;
    h[4]= gt_rb (h[3]);
    h[5]= gt_ls (h[0]);

	    return (CLR_TYPE) fdclr (c_legend,h[0], nar);
  case 11:
    h[0]= gt_ft (r);
    heval (h[0], h);
   return (CLR_TYPE) FALSE;
  case 12:
    h[0]= gt_ft (r);
    heval (h[0], h);

      return (CLR_TYPE) fdclr (c_legend,h[0], nar);
  case 13:
    h[0]= gt_ft (r);
    heval (h[0], h);
   return (CLR_TYPE) FALSE;
  case 14:
    h[0]= gt_ft (r);
    heval (h[0], h);

      return (CLR_TYPE) fdclr (c_legend,h[0], nar);
  case 15:
    h[0]= gt_ft (r);
    h[1]= gt_fs (h[0]);
    h[3]= r;
    h[4]= gt_rb (h[3]);
    h[5]= gt_ls (h[0]);
   return (CLR_TYPE) FALSE;
  case 16:
    h[0]= gt_ft (r);
    h[1]= gt_fs (h[0]);
    h[5]= gt_ls (h[0]);

	   return (CLR_TYPE) INTcons (mygetlexv((TNODE*)h[1]), (INTlist)NULL);
  case 17:
    h[0]= gt_ft (r);
    h[1]= gt_fs (h[0]);
    h[4]= r;
    h[3]= gt_lb (h[4]);
    h[5]= gt_ls (h[0]);

	    return (CLR_TYPE) INT2cons (mygetlexv((TNODE*)h[4]),
			    COMMA, (INTlist)fdclr (c_legend,h[3], nar));
  case 18:
    h[0]= r;
    h[1]= gt_fs (h[0]);
    h[5]= gt_ls (h[0]);

	    return (CLR_TYPE)  fdclr (c_legend,h[5], nar);
  case 19:
    h[0]= gt_ft (r);
    heval (h[0], h);
   return (CLR_TYPE) FALSE;
  case 20:
    h[0]= r;
    heval (h[0], h);

     if (find_attr (c_iddec, h[1]) != NULL)
	return (CLR_TYPE) putid (mygetlexv ((TNODE*)h[1]),
		     TPROC,
		     (int)fdclr (c_iddec,h[1], nar),
		     c_iddec,
		     *(int*)fdclr (c_line,h[1], nar),
		     (INTlist)fdclr (c_legend,h[2], nar));
     else  return (CLR_TYPE) putid ((int)fdclr (c_lexv,h[1], nar),
			TPROC,
			0,
			c_idref,
			*(int*)fdclr (c_line,h[1], nar),
			(INTlist)fdclr (c_legend,h[2], nar));
  case 21:
    h[0]= r;
    heval (h[0], h);

     if ((h[1] == NULL) && (h[2] == NULL))
	return (CLR_TYPE) fdclr (c_legend,h[3], nar);
     if ((h[1] != NULL) && (h[2] == NULL))
	return (CLR_TYPE) INTappend ((INTlist)fdclr (c_legend,h[1], nar),
			 (INTlist)fdclr (c_legend,h[3], nar));
     if ((h[1] == NULL) && (h[2] != NULL))
	return (CLR_TYPE) INTappend ((INTlist)fdclr (c_legend,h[2], nar),
			 (INTlist)fdclr (c_legend,h[3], nar));
      return (CLR_TYPE) INTappend (
	       INTappend ((INTlist)fdclr (c_legend,h[1], nar),
			  (INTlist)fdclr (c_legend,h[2], nar)),
	       (INTlist)fdclr (c_legend,h[3], nar));
  case 22:
    h[0]= r;
    heval (h[0], h);

      return (CLR_TYPE) INTappend (
       INTcons (LEFT_BRACKET, (INTlist)fdclr (c_legend,h[1], nar)),
       INTcons (RIGTH_BRACKET, (INTlist) NULL));
  case 23:
    h[0]= r;
    heval (h[0], h);

      return (CLR_TYPE) INTappend (
	       INTcons (LEFT_PAREN, (INTlist)fdclr (c_legend,h[1], nar)),
	       INTcons (RIGTH_PAREN, (INTlist) NULL));
  case 24:
    h[0]= r;
    heval (h[0], h);

     if (h[1] != NULL)
	return (CLR_TYPE) INTappend (INTcons (EXIT_PAREN,(INTlist)fdclr (c_legend,h[1], nar)),
			 INTcons (RIGTH_PAREN, (INTlist) NULL));
     else  return (CLR_TYPE) INTcons (COLON_EXIT, (INTlist) NULL);
  case 25:
    h[0]= r;
    heval (h[0], h);

      return (CLR_TYPE) INTcons (COLON_NOEXIT, (INTlist) NULL);
  case 26:
    h[0]= gt_ft (r);
    h[1]= gt_fs (h[0]);
    h[3]= r;
    h[4]= gt_rb (h[3]);
    h[5]= gt_ls (h[0]);
   return (CLR_TYPE) FALSE;
  case 27:
    h[0]= gt_ft (r);
    h[1]= gt_fs (h[0]);
    h[5]= gt_ls (h[0]);

	    return (CLR_TYPE) INTcons (mygetlexv((TNODE*)h[1]),(INTlist)NULL);
  case 28:
    h[0]= gt_ft (r);
    h[1]= gt_fs (h[0]);
    h[4]= r;
    h[3]= gt_lb (h[4]);
    h[5]= gt_ls (h[0]);

	     return (CLR_TYPE) INT2cons (mygetlexv((TNODE*)h[4]),
			     COMMA, (INTlist)fdclr (c_legend,h[3], nar));
  case 29:
    h[0]= r;
    h[1]= gt_fs (h[0]);
    h[5]= gt_ls (h[0]);

	     return (CLR_TYPE)  INTrev ((INTlist)fdclr (c_legend,h[5], nar));
  case 30:
    h[0]= gt_ft (r);
    heval (h[0], h);
   return (CLR_TYPE) FALSE;
  case 31:
    h[0]= gt_ft (r);
    heval (h[0], h);

      return (CLR_TYPE) mygetlexv ((TNODE*)h[2]);
  case 32:
    h[0]= gt_ft (r);
    heval (h[0], h);

      return (CLR_TYPE) TVAL;
  case 33:
    h[0]= gt_ft (r);
   return (CLR_TYPE) FALSE;
  case 34:
    h[0]= r;
    heval (h[0], h);

     if (find_attr (c_idref,h[2]) != NULL)
	return (CLR_TYPE) putid (mygetlexv ((TNODE*)h[2]),
		     TPROC,
		     (int)fdclr (c_idref,h[2], nar),
		     c_idref,
		     *(int*)fdclr (c_line,h[2], nar),
		     (INTlist)NULL);
     else  return (CLR_TYPE) putid ((int)fdclr (c_lexv,h[2], nar),
			TPROC,
			0,
			c_idref,
			*(int*)fdclr (c_line,h[2], nar),
			(INTlist)NULL);
  case 35:
    h[0]= r;
    h[1]= gt_fs (h[0]);
    h[5]= gt_ls (h[0]);

     /* Si hay un "of sort" en la value_expression, se debe incluir */
     /* como idref que es de ese sort */
     if (find_attr (c_ofsort, h[0]) != NULL)
       if (find_attr (c_sidref, h[0]) != NULL)
	 (void) putid((int)fdclr (c_ofsort,h[0], nar),
		      TSORT,
		      (int)fdclr (c_sidref,h[0], nar),
		      c_idref,
		      *(int*)fdclr (c_line,h[0], nar),
		      (INTlist)NULL);
       else (void) putid ((int)fdclr (c_ofsort,h[0], nar),
			  TSORT,
			  0,
			  c_idref,
			  *(int*)fdclr (c_line,h[0], nar),
			  (INTlist)NULL);
     if (find_attr (c_idref,h[0]) != NULL)
	return (CLR_TYPE) putid (mygetlexv ((TNODE*)h[0]),
		     (int)ATable->data[(int)fdclr (c_idref,h[0], nar)].value0,
		     (int)fdclr (c_idref,h[0], nar),
		     c_idref,
		     *(int*)fdclr (c_line,h[0], nar),
		     (INTlist)NULL);
     else  return (CLR_TYPE) putid ((int)fdclr (c_lexv,h[0], nar),
			TVAL,
			0,
			c_idref,
			*(int*)fdclr (c_line,h[0], nar),
			(INTlist)NULL);
  case 36:
    h[0]= gt_ft (r);
    h[1]= gt_fs (h[0]);
    h[5]= gt_ls (h[0]);

	     return (CLR_TYPE) fdclr (c_legend,h[1], nar);
  case 37:
    h[0]= gt_ft (r);
    h[1]= gt_fs (h[0]);
    h[4]= r;
    h[3]= gt_lb (h[4]);
    h[5]= gt_ls (h[0]);

	     return (CLR_TYPE) INTappend((INTlist)fdclr (c_aux_legend,h[3], nar),
		   INTcons (COMMA,(INTlist)fdclr (c_legend,h[4], nar)));
  case 38:
    h[0]= r;
    h[1]= gt_fs (h[0]);
    h[5]= gt_ls (h[0]);

	     return (CLR_TYPE)  fdclr (c_aux_legend,h[5], nar);
  case 39:
    h[0]= gt_ft (r);
    heval (h[0], h);
   return (CLR_TYPE) FALSE;
  case 40:
    h[0]= gt_ft (r);
    heval (h[0], h);

      return (CLR_TYPE) TVAL;
  case 41:
    h[0]= gt_ft (r);
    heval (h[0], h);

      return (CLR_TYPE) mygetlexv ((TNODE*)h[2]);
  case 42:
    h[0]= r;
    heval (h[0], h);

      return (CLR_TYPE) INTappend ((INTlist)fdclr (c_legend,h[1], nar),
		       INT2cons (COLON, mygetlexv ((TNODE*)h[2]),
				(INTlist) NULL));
  case 43:
    h[0]= gt_ft (r);
    h[1]= gt_fs (h[0]);
    h[5]= gt_ls (h[0]);

	    return (CLR_TYPE) INTcons (mygetlexv((TNODE*)h[1]),(INTlist)NULL);
  case 44:
    h[0]= gt_ft (r);
    h[1]= gt_fs (h[0]);
    h[4]= r;
    h[3]= gt_lb (h[4]);
    h[5]= gt_ls (h[0]);

	     return (CLR_TYPE) INT2cons (mygetlexv ((TNODE*)h[4]),
			     COMMA,(INTlist)fdclr (c_legend,h[3], nar));
  case 45:
    h[0]= r;
    h[1]= gt_fs (h[0]);
    h[5]= gt_ls (h[0]);

	     return (CLR_TYPE)  INTrev ((INTlist)fdclr (c_legend,h[5], nar));
  case 46:
    h[0]= gt_ft (r);
    heval (h[0], h);

      return (CLR_TYPE) TGATE;
  case 47:
    h[0]= gt_ft (r);
    h[1]= gt_fs (h[0]);
    h[3]= r;
    h[4]= gt_rb (h[3]);
    h[5]= gt_ls (h[0]);

	     return (CLR_TYPE) fdclr (c_gateoval,h[0], nar);
  case 48:
    h[0]= gt_ft (r);
    h[1]= gt_fs (h[0]);
    h[3]= r;
    h[4]= gt_rb (h[3]);
    h[5]= gt_ls (h[0]);

	    if ((int)fdclr (c_gateoval,h[0], nar) == TVAL)
	       return (CLR_TYPE) INTcons ((int)fdclr (c_sname,h[0], nar),
			      (INTlist) NULL);
	    else  return (CLR_TYPE) ((INTlist) NULL);
  case 49:
    h[0]= gt_ft (r);
    h[1]= gt_fs (h[0]);
    h[5]= gt_ls (h[0]);

	     return (CLR_TYPE) INTcons (mygetlexv ((TNODE*)h[1]), (INTlist) NULL);
  case 50:
    h[0]= gt_ft (r);
    h[1]= gt_fs (h[0]);
    h[4]= r;
    h[3]= gt_lb (h[4]);
    h[5]= gt_ls (h[0]);

	     return (CLR_TYPE) INT2cons (mygetlexv ((TNODE*)h[4]),
			     COMMA, (INTlist)fdclr (c_aux_legend,h[3], nar));
  case 51:
    h[0]= r;
    h[1]= gt_fs (h[0]);
    h[5]= gt_ls (h[0]);

	     return (CLR_TYPE)  INTrev ((INTlist)fdclr (c_aux_legend,h[5], nar));
  case 52:
    h[0]= r;
    heval (h[0], h);

     if (find_attr (c_iddec,h[0]) != NULL)
	return (CLR_TYPE)
	 putid (mygetlexv ((TNODE*)h[0]),
		TTYPE,
		(int)fdclr (c_iddec,h[0], nar),
		c_iddec,
		*(int*)fdclr (c_line,h[0], nar),
		(INTlist) NULL);
     else if (find_attr (c_idref,h[0]) != NULL)
	     return (CLR_TYPE) putid (mygetlexv ((TNODE*)h[0]),
			  TTYPE,
			  (int)fdclr (c_idref,h[0], nar),
			  c_idref,
			  *(int*)fdclr (c_line,h[0], nar),
			  (INTlist)NULL);
    else  return (CLR_TYPE) putid ((int)fdclr (c_lexv,h[0], nar),
			TTYPE,
			0,
			c_idref,
			*(int*)fdclr (c_line,h[0], nar),
			(INTlist)NULL);
  case 53:
    h[0]= r;
    heval (h[0], h);

     if (fdclr (c_isname,h[0], nar)) {
	return (CLR_TYPE) putid ((int)fdclr (c_lexv,h[0], nar),
		      TNAME,
		      0,
		      c_idref,
		      *(int*)fdclr (c_line,h[0], nar),
		      (INTlist)NULL);
     }
     else {
       if (find_attr (c_iddec,h[0]) != NULL)
	  return (CLR_TYPE) putid (mygetlexv ((TNODE*)h[0]),
		     TSORT,
		     (int)fdclr (c_iddec,h[0], nar),
		     c_iddec,
		     *(int*)fdclr (c_line,h[0], nar),
		     (INTlist)NULL);
       else if (find_attr (c_idref,h[0]) != NULL)
	     return (CLR_TYPE) putid (mygetlexv ((TNODE*)h[0]),
			  TSORT,
			  (int)fdclr (c_idref,h[0], nar),
			  c_idref,
			  *(int*)fdclr (c_line,h[0], nar),
			  (INTlist)NULL);
       else  return (CLR_TYPE) putid ((int)fdclr (c_lexv,h[0], nar),
			TSORT,
			0,
			c_idref,
			*(int*)fdclr (c_line,h[0], nar),
			(INTlist)NULL);
     };
  case 54:
    h[0]= r;
    heval (h[0], h);

     if (fdclr (c_isname,h[0], nar)) {
	return (CLR_TYPE) putid ((int)fdclr (c_lexv,h[0], nar),
		     TNAME,
		     0,
		     c_idref,
		     *(int*)fdclr (c_line,h[0], nar),
		     (INTlist)NULL);
     }
     else {
       if (find_attr (c_iddec,h[0]) != NULL)
	  return (CLR_TYPE) putid (
		mygetlexv ((TNODE*)h[0]),
		(int)ATable->data[(int)fdclr (c_iddec,h[0], nar)].value0,
								   /* idclass */
		(int)fdclr (c_iddec,h[0], nar),
		c_iddec,
		*(int*)fdclr (c_line,h[0], nar),
		(INTlist)fdclr (c_legend,h[0], nar));
       else if (find_attr (c_idref,h[0]) != NULL)
	  return (CLR_TYPE) putid (
		mygetlexv ((TNODE*)h[0]),
		   (int)ATable->data[(int)fdclr (c_idref,h[0], nar)].value0,
								   /* idclass */
		   (int)fdclr (c_idref,h[0], nar),
		   c_idref,
		   *(int*)fdclr (c_line,h[0], nar),
		   (INTlist)NULL);
       else  return (CLR_TYPE) putid ((int)fdclr (c_lexv,h[0], nar),
			TVAL,
			0,
			c_idref,
			*(int*)fdclr (c_line,h[0], nar),
			(INTlist)NULL);
   };
  case 55:
    h[0]= r;
    heval (h[0], h);

     if (fdclr (c_isname,h[0], nar)) {
	return (CLR_TYPE) putid ((int)fdclr (c_lexv,h[0], nar),
		     TNAME,
		     0,
		     c_idref,
		     *(int*)fdclr (c_line,h[0], nar),
		     (INTlist)NULL);
     }
     else {
       if (find_attr (c_iddec,h[0]) != NULL)
	  return (CLR_TYPE) putid (
		mygetlexv ((TNODE*)h[0]),
		(int)ATable->data[(int)fdclr (c_iddec,h[0], nar)].value0,
								   /* idclass */
		(int)fdclr (c_iddec,h[0], nar),
		c_iddec,
		*(int*)fdclr (c_line,h[0], nar),
		(INTlist)fdclr (c_legend,h[0], nar));
       else if (find_attr (c_idref,h[0]) != NULL)
	  return (CLR_TYPE) putid (
		   mygetlexv ((TNODE*)h[0]),
		   (int)ATable->data[(int)fdclr (c_idref,h[0], nar)].value0,
								   /* idclass */
		   (int)fdclr (c_idref,h[0], nar),
		   c_idref,
		   *(int*)fdclr (c_line,h[0], nar),
		   (INTlist)NULL);
       else  return (CLR_TYPE) putid ((int)fdclr (c_lexv,h[0], nar),
			TVAL,
			0,
			c_idref,
			*(int*)fdclr (c_line,h[0], nar),
			(INTlist)NULL);
   };
  case 56:
    h[0]= r;
    heval (h[0], h);

     if (find_attr (c_iddec,h[0]) != NULL)
	return (CLR_TYPE) putid (mygetlexv ((TNODE*)h[0]),
		     TGATE,
		     (int)fdclr (c_iddec,h[0], nar),
		     c_iddec,
		     *(int*)fdclr (c_line,h[0], nar),
		     (INTlist)NULL);
     else if (find_attr (c_idref, h[0]) != NULL)
	     return (CLR_TYPE) putid (mygetlexv ((TNODE*)h[0]),
			  TGATE,
			  (int)fdclr (c_idref,h[0], nar),
			  c_idref,
			  *(int*)fdclr (c_line,h[0], nar),
			  (INTlist)NULL);
     else  return (CLR_TYPE) putid ((int)fdclr (c_lexv,h[0], nar),
			TGATE,
			0,
			c_idref,
			*(int*)fdclr (c_line,h[0], nar),
			(INTlist)NULL);
  case 57:
    h[0]= r;
    heval (h[0], h);

     if (find_attr (c_iddec,h[0]) != NULL)
	return (CLR_TYPE) putid (mygetlexv ((TNODE*)h[0]),
		     (int)ATable->data[(int)fdclr (c_iddec,h[0], nar)].value0,
		     (int)fdclr (c_iddec,h[0], nar),
		     c_iddec,
		     *(int*)fdclr (c_line,h[0], nar),
		     (INTlist)fdclr (c_legend,h[0], nar));
     else if (find_attr (c_idref,h[0]) != NULL)
	     return (CLR_TYPE) putid (mygetlexv ((TNODE*)h[0]),
			  (int)ATable->data[(int)fdclr (c_idref,h[0], nar)].value0,
								 /* idclass */
			  (int)fdclr (c_idref,h[0], nar),
			  c_idref,
			  *(int*)fdclr (c_line,h[0], nar),
			  (INTlist)NULL);
     else  return (CLR_TYPE) putid ((int)fdclr (c_lexv,h[0], nar),
			(int)fdclr (c_gateoval,h[0], nar),
			0,
			c_idref,
			*(int*)fdclr (c_line,h[0], nar),
			(INTlist)NULL);
     }
  return (CLR_TYPE)NULL;
}





PUBLIC void
rag (r)
    TNODE* r;
{
  PROCESINI (r);
  if (ragerrors == 0)
    todo (r);
} /* end of rag */
