/*
 *  MODULE  : scan.c
 *  The scanner reads one Pascal symbol, also initializes symbol tables.
{*  last modification:  26.10.92  12:26   }


 *   uli 28.01.91 : sym_is[].leftexpr added.
 *   uli 31.01.91 : errors in real-constant report position of "." or "e".
 *   uli 14.02.91 : rightbin: all nodes may have right son
 *   uli 20.02.91 : symbuf overflow will be checked.
 *   uli 06.03.91 : new style headers.
 *   uli 15.04.91 : cEndofSrc has priority priobegin now.
 *   uli 16.04.91 : priorities of decl- and type-keywords adapted.
 *                  set of type starters add.
 *                  cLParU and cLParD added.
 *   uli 25.04.91 : symkeyword: leftexpr will be toggled too.
 *   uli 30.04.91 : cPCast and cFree added.
 *   uli 13.05.91 : cNOT has C-priority priomonop, prionotop is obsolete.
 *   uli 15.05.91 : rightexpr added.
 *   uli 09.07.91 : scaninit : std_procdre defined.
 *   uli 19.07.91 : symctext improved
 *   uli 06.08.91 : cPTRCHAR cSIZEOF added.
 *   uli 09.08.91 : cINT_OF_C cFILE_OF_C cPOINTER_OF_C added.
 *   uli 12.09.91 : getch changed to scanch.
 *   uli 27.11.91 : symptext of constants improved.
 *   uli 28.11.91 : symprio : "enum symc" replaced by symctype.
 *   uli 10.12.91 : prio of cUSE changed to priostm.
 *   uli 23.01.92 : cIDOT etc. added.
 *   uli 13.05.92 : sym_is[].lvalue added.
 *   uli 14.05.92 : NOBRACKETS added, and long lines truncated.
 *   PJ  31.07.92 : Implement trigraph characters - using NOBRACKETS -
                    for IBM-CMS-Compilers
 *   PJ  04.08.92 : variables for DEMOVERSION variable restriction added.
 *   PJ  13.08.92 : error in scanning treegraph characters removed.
 *   PJ  13.10.92 : @ as substitute for ^ allowed.
 *   tim 26.10.92 : handling of new standard function ALLOCATE  added
*/

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <limits.h>
#include <string.h>

#include            "impor.t"
#include "option.h"
#include "sysutil.h"            /* import finish */
#include "error.h"

#include            "expor.t"
#include "scan.h"

#include            "implemen.t"

#ifdef LINT_ARGS
local void scanch      (void);
local void skipline    (void);
local void skipcomment (void);
local void directive   (void);
#else
local void scanch ();
local void skipline ();
local void skipcomment ();
local void directive ();
#endif


boolean  in_terminal = false ;

static FILE * srcfile ; /* source file */
static shortint srcch ; /* char from original source file */
static FILE * incfile ; /* include file or source file */
static shortint ch1   ; /* character to be analysed */
static shortint ch2   ; /* one character look ahead */
static shortint ln=1 ;  /* line number of character ch1 */
static shortint oldln;  /* line number of last non-$-line */
static shortint cl=0 ;  /* column number of character ch1 */
static shortint oldcl;  /* column number of last EOLN. */
static shortint col  ;  /* dbx doesnt support cast-op, thus copy of pos.col */
static boolean  org=0;  /* if false, then upper caser letters are returned */


                                                  /*-----------------*/
#ifdef LINT_ARGS
global void opensrc  (char *nam )
#else
global void opensrc (nam)                         /*  o p e n s r c  */
           /* Opens the source file named nam */
char *nam ;
#endif
BEGIN(opensrc)
  if  (in_terminal)  then   srcfile=stdin;
  else if ( (srcfile = fopen(nam, "r") ) == NULL )
    fprintf (stderr, "Source file %s not found.\n",nam), finish (-1) ;
  incfile = srcfile ;
  ch2 = ' ' ;
  scanch () ;            /* look ahead */
  ln = 1 ;
  cl = 0 ;
END /* opensrc */

                                                /*-------------------*/
#ifdef LINT_ARGS
global void closesrc  ( void)
#else
global void closesrc ()                         /*  c l o s e s r c  */
#endif
BEGIN(closesrc)
  if (srcfile)
     fclose (srcfile) ,
     srcfile = (FILE*)0 ;
  if (incfile)
     fclose (incfile) ,
     incfile = (FILE*)0 ;
END

                                                /*-------------------*/
#ifdef LINT_ARGS
local void skipline  ( void)
#else
local void skipline ()                          /*  s k i p l i n e  */
  /* skips one source line of a $ line */
#endif
BEGIN(skipline)
  while (ch2!='\n' and ch2!=EOF)   ch2= fgetc(incfile);
  if (incfile==srcfile) then   ln++;
               /* no line counting in include */
  ch1 = ch2 ;
END /* skipline */

                                                /*---------------------*/
#ifdef LINT_ARGS
local void directive  (  void)
#else
local void directive ()                         /*  d i r e c t i v e  */
  /* reads a compiler directive, i.e. $ line. */
  /* At return the source is positioned at cl = 0, ch1 = '\n' or EOF. */
  /* oldln and oldcl must be unchanged! */
#endif
BEGIN(directive)
  char filename[FILENAME_MAX+1] ;
  register shortint ch;
  register short int i ;

   ch = ch2 ;
   if  (ch=='I' or ch=='i')  then
    begin                                     /* $INCLUDE found */
     if  (incfile!=srcfile)  then
       fprintf (stderr, "Nested INCLUDE is not allowed\n"), finish (-999) ;
     do   ch= fgetc(incfile);
     while (ch!=' ' and ch!='\t' and ch!='\n' and ch!=EOF) ;

     while (ch==' ' or ch=='\t' )
       ch= fgetc(incfile);                    /* search filename */
     i = 0 ;
     while (ch!=' ' and ch!='\t' and ch!='\n' and ch!=EOF and
            i < FILENAME_MAX )
       filename[i++] = ch ,
       ch= fgetc(incfile);                    /* copy filename */
     filename[i] = '\0' ;
     while (ch!=EOF and ch!='\n' )            /* skip line without */
        ch= fgetc(incfile);                       /* ln update     */
     srcch = ch ; /* save last char read */

     if  ((incfile= fopen (filename,"r")) == 0)  then  /*  o p e n  */
       fprintf (stderr,
          "INCLUDE file %s not found\n", filename) ,
       finish (-1) ;
     ch1 = '\n' ; /* before first char of include file */
    end                                         /* end INCLUDE  */
   else

   if  ((ch=='O' or ch=='o')  and
        ( (ch= fgetc(incfile)) =='F' or ch=='f'))  then
    begin                                      /* $OFF found */
     ch2 = ch ;
     do    /* until $ON found */
      begin
        skipline () ;
        if  ((ch= fgetc(incfile)) =='$')  then
          if  ( (ch= fgetc(incfile)) =='O' or ch=='o')  then
            if  ( (ch= fgetc(incfile)) =='N' or ch=='n')  then
             begin
               ch2 = ch ;
               skipline () ;
               ch = ch2 ;
               break ;
             end
        ch2 = ch ;
      end
     while (ch!=EOF ) ;
    end                                         /* $ON          */
   else
     skipline () ;                              /* $ comment line */

   /* ch1 set by skipline */
   ch2 = fgetc(incfile);      /* look ahead */
   cl = 0 ;
END /* directive */                             /*  d i r e c t i v e  */
                                                /*---------------------*/

                                                /*---------------*/
                                                /*  s c a n c h  */
#ifdef LINT_ARGS
local void scanch (  void)
#else
local void scanch()
  /* reads one character from sourcefile and          */
  /* stores it in ch1,   ch2 is the following character */
  /* and handles end of line situation */
#endif
BEGIN(scanch)
 ch1 = ch2 ;            /* one character look ahead */
 ch2 = fgetc(incfile);
 cl++ ;

 if (ch1=='\n') then                            /* handle end of line */
 begin
  oldln = ln ;
  if (incfile==srcfile) then   ln++;
                        /* no line counting in include */
  oldcl = cl ;
  cl = 0 ;
#ifdef TRACE
  printf("Line %d\n",line);
#endif
 end
END /* scanch */                                /*  s c a n c h  */
                                                /*---------------*/

                                                /*-------------------------*/
#ifdef LINT_ARGS
local void skipcomment  ( void)
#else
local void skipcomment ()                       /*  s k i p c o m m e n t  */
#endif
BEGIN(skipcomment)
   boolean not_exceeds_line = true ;

   scanch () ; /* skip comment leader */
   /* if (ch1 == '$') then   option () ; */

   while (not (ch1=='*' and ch2==')') and (ch1!='}') and (ch1!=EOF))
     begin
       if  (ch1=='\n' and not_exceeds_line)  then
        begin                                  /* comment exceeds line */
          not_exceeds_line = false ;
          if  (oldcl<=SYMSIZE)  then   pos.line = oldln,
              pos.col = (byte) oldcl ;
          else  pos.line = ln , pos.col = 1 ;
          errput (12, pos, (char*)0) ;
         /* print ("Comment exceeds line.") ;
          printline () ; */
        end
       scanch();
     end
   if  (ch1=='*')  then   scanch() ;
   if  (ch1!=EOF)  then   scanch();
END /* skipcomment */


/* PJ 31.07.92 */

#ifdef LINT_ARGS
local void char_error( postype errpos )
#else
local void char_error( errpos )
  postype errpos;
#endif

/* Give error message "Illegal character in text" at position errpos
   and read the next character
*/

{ char num[4] ;

  sprintf(num, "%d", (int) ch1);
  errpos.line = ln;
  errpos.col = cl;
  errput(8004, errpos, num);
  scanch( );
}

/* END PJ 31.07.92 */

                                                /*---------------*/
                                                /*  g e t s y m  */
#ifdef LINT_ARGS
global symctype  getsym  (  register char * string[] )
#else
global symctype  getsym (string)
  /* returns the next symbol as symbol code and/or string */
  /* The string must be copied before the next call of getsym. */
 register char * string[] ;

#endif
BEGIN(getsym)

#define nchar    begin symbuf[l]= ch1; l++; scanch(); end
#define ncharup  begin symbuf[l]= (islower(ch1) ? toupper(ch1) : ch1); l++; scanch(); end
#define skip     while (ch1==' ' or ch1=='\t' or ch1=='\n' or ch1==10 or ch1==13) scanch()

register symctype  symc ;        /* result symbol code */
static   char symbuf[SYMSIZE+2]; /* string buffer , + 2 chars for security */
register shortint    l =0;       /* counter in symbuf */
         postype   errpos;       /* position of a scanner error */

 *string = (char *) 0 ;
 symc = cNosym ;
 do                                           /* until symbol found */
 begin
  skip;

  col = cl ; /* used by dbx */
  pos.line = ln ;   /* starting position of symbol */
  if  (cl<=SYMSIZE)  then
       pos.col = (byte)  cl ;
   else
     begin
       pos.col = (byte) SYMSIZE ;
       errput (902, pos, (char*)0 ) ;
      /* print ("Source line tooo lloonngg.") ;
       printline () ; */
     end ;

  if  (ch1==EOF)  then
    if  (incfile != srcfile)  then
     begin                                      /* leave include file */
       fclose (incfile) ;
       incfile = srcfile ;
       ch2 = srcch ;
       scanch () ;
     end
    else
     symc = cEndofSrc ;                         /* end of source file */
  else

  if  (isletter(ch1))
   begin                                     /* identifier or keyword */
    if (org) then
     do  nchar    while ((isletter(ch1) or isdigit(ch1)) and l<SYMSIZE) ;
    else
     do  ncharup  while ((isletter(ch1) or isdigit(ch1)) and l<SYMSIZE) ;
    *string = symbuf ;
    symc = cIdent ;
   end
  else

  if  (isdigit(ch1))
  begin                                    /* numerical constant */
   do  nchar  while (isdigit(ch1) and l<SYMSIZE) ;
   *string = symbuf ;
   symc = cIcon ;
   if (ch1=='.')
   begin
    if (ch2==')' or ch2=='.') ;       /* cRBrack or cTill found behind int */
     else
      begin
       symc = cRcon ;
       nchar ;
       if (isdigit(ch1))                       /* real constant */
          do  nchar  while (isdigit(ch1) and l<SYMSIZE) ;
       else
        begin
          if (cl)  errpos.line = ln , errpos.col = cl-1 ;
          else     errpos.line = oldln , errpos.col = oldcl ;
          errput (8001, errpos, (char*)0) ;
        /*  printf ("Missing fraction part of real constant\n") ; */
          symbuf[l++]='0';
        end
       while  (**string == '0')  (*string)++ ;    /* skip leading zeroes */
       if  (**string == '.')  (*string)-- ;       /* one zero before "." */
      end  /* not ".." nor ".)" following */
   end
   if ((ch1=='e') or (ch1=='E'))                     /* exponent found */
   begin
    symc = cRcon ;
    ch1 = 'E' ; /* upper case e */
    nchar;
    if ((ch1=='+') or (ch1=='-')) nchar;
    if (isdigit(ch1))
      do  nchar  while (isdigit(ch1) and l<SYMSIZE) ;
    else
     begin
       if (cl)  errpos.line = ln , errpos.col = cl-1 ;
       else     errpos.line = oldln , errpos.col = oldcl ;
       errput (8002, errpos, (char*)0) ;
     /*  print ("Missing exponent of real constant") ;
       printline () ; */
       symbuf[l] = '0' ; l++ ;   /* insert a zero */
     end
    while  (**string == '0')  (*string)++ ;    /* skip leading zeroes */
    if  (**string == '.')  (*string)-- ;       /* one zero before "." */
   end  /* exponent found */
  end else                                        /* end numerical const */

  begin                                           /* non alphanumeric */
   switch (ch1)
   begin
     case '\'':  scanch();                               /* string constant */
                 while ( ch1!=EOF and l<SYMSIZE )  /* until end of string */
                 begin
                  while ((ch1!='\'') and (ch1!='\n') and (ch1!=EOF)
                         and (l<SYMSIZE))    nchar ;
                  if (ch1=='\'')
                   begin
                     if (ch2!='\'')  then   break ;    /* end of string */
                     else
                       begin
                         scanch () ;  /* skip quote */
                         nchar ; continue ;            /* '' found */
                       end ;
                   end
                  else
                    begin
                      errpos.line = oldln ; errpos.col = oldcl ;
                      errput (8003, errpos, (char*)0 ) ;
                    /*  print ("A string constant must not exceed a line.") ;
                      printline () ; */
                      break ;
                    end
                 end    /* of string constant */
                 *string = symbuf ;
                 symc = (l==1 ? cCcon : cScon) ;                 break;

                                               /* non alphanumeric symbol */
     case '+' :
                 if (ch2=='<')   symc = cPlusD  , scanch() ;  else
                 if (ch2=='>')   symc = cPlusU  , scanch() ;  else
                 if (ch2=='*')   symc = cCohu   , scanch() ;  else
                                 symc = cPlus   ;                 break;
     case '*' :
                 if (ch2=='<')   symc = cMultD  , scanch() ;  else
                 if (ch2=='>')   symc = cMultU  , scanch() ;  else
                 if (ch2=='*')   symc = cConj   , scanch() ;  else
                                 symc = cMult   ;                 break;
     case '-' :
                 if (ch2=='<')   symc = cMinusD , scanch() ;  else
                 if (ch2=='>')   symc = cMinusU , scanch() ;  else
                                 symc = cMinus  ;                 break;
     case '/' :
                 if (ch2=='<')   symc = cDivD   , scanch() ;  else
                 if (ch2=='>')   symc = cDivU   , scanch() ;  else
                                 symc = cDiv    ;                 break;
     case '<' :
                 if (ch2=='=')   symc = cLE     , scanch() ;  else
                 if (ch2=='>')   symc = cNE     , scanch() ;  else
                                 symc = cLT     ;                 break;
     case '>' :
                 if (ch2=='=')   symc = cGE     , scanch() ;  else
                 if (ch2=='<')   symc = cDisj   , scanch() ;  else
                                 symc = cGT     ;                 break;
     case ':' :
                 if (ch2=='=')   symc = cAssign , scanch() ;  else
                                 symc = cColon  ;                 break;
     case '.' :
                 if (ch2=='.')   symc = cTill   , scanch() ;  else
                 if (ch2==')')   symc = cRBrack , scanch() ;  else
                                 symc = cPoint  ;                 break;
     case '#' :
                 if (ch2=='<')   symc = cDotD   , scanch() ;  else
                 if (ch2=='>')   symc = cDotU   , scanch() ;  else
                 if (ch2=='*')   symc = cDotN   , scanch() ;  else
                 if (ch2=='#')   symc = cDotS   , scanch() ;  else
                                 symc = cDot    ;                 break;
     case '(' :
                 if (ch2=='.')   symc = cLBrack , scanch() ;  else
                 if (ch2=='<')   symc = cLParD ,  scanch() ;  else
                 if (ch2=='>')   symc = cLParU ,  scanch() ;  else
                 if (ch2=='*')   scanch() , skipcomment () ;  else
                                 symc = cLParent ;                break;

     case '{' :   skipcomment () ;                  break;
     case ',' :   symc = cComma ;                   break;
     case ';' :   symc = cSemicolon ;               break;
     case ')' :   symc = cRParent ;                 break;

/* PJ 31.07.92 */

#ifdef NOBRACKETS
     case '?' : if ( ch2 == '?' )
                { scanch( );
                  scanch( );
                  switch ( ch1 )
                  { case '('  : symc = cLBrack;
                                break;
                    case ')'  : symc = cRBrack;
                                break;
                    case '\'' : symc = cArrow;
                                break;
                    default   : char_error( errpos );
                                break;
                  }
                }
                else
                  char_error( errpos );
                break;
#else
     case '[' :   symc = cLBrack;                   break;
     case ']' :   symc = cRBrack;                   break;
     case '^' :   symc = cArrow ;                   break;
#endif

/* END PJ 31.07.92 */

     case '=' :   symc = cEQ    ;                   break;
     case '@' :   symc = cArrow;                    break;  /* P.J. 13.10.92 */
     case '$' :  if  (cl==1)  then
                  begin   directive () ;
                                                    break;
                  end ; /* else error */
     default  : char_error( errpos );    /* PJ 31.07.92 */
                break;
   end /* switch ch1 */
   if  (symc)  then   scanch () ;
  end /* no alphanumeric symbol */

 end  /* until symbol found or EOF */
 while (symc == cNosym) ;                       /* until symbol found */

 if  (l>=SYMSIZE)
   begin  errpos.line = ln ;
          if  (cl<=SYMSIZE)  then  errpos.col = cl ;
                             else  errpos.col = SYMSIZE ;
          errput (903, errpos, NULL) ;
   end ;

 symbuf[l]='\0';
 RETURN(symc);
END /* getsym */                                /*  g e t s y m  */
                                                /*---------------*/


                                                /*-----------------------*/
#ifdef LINT_ARGS
global void  symkeyword (  symctype symc ,register boolean v )
#else
global void  symkeyword(symc, v)                /*  s y m k e y w o r d  */
 /* switches the symbol symc to keyword, if v = true */
 /* switches the symbol symc to identifier, if v = false */
 /* modifies only the symbol sets */
 /* Now it's only used for cSUM */
 symctype symc ;
 register boolean v ;
#endif
BEGIN(symkeyword)
  sym_is[symc].identifier  =
  sym_is[symc].variable    =
  sym_is[symc].operand     =
  sym_is[symc].userdefined = not v ;
  sym_is[symc].leftbin     = v ;
  sym_is[symc].leftexpr    = v ;
END /* symkeyword */                            /*  s y m k e y w o r d  */
                                                /*-----------------------*/


#ifdef LINT_ARGS
global void  symsetorg ( register boolean v )
#else
global void  symsetorg(v)
 register boolean v ;
#endif
BEGIN(symsetorg)
  org = v ;
END /* symsetorg */


#ifdef LINT_ARGS
global short int symprio  ( symctype  symc )
#else
global short int symprio (symc)
  symctype  symc ;
#endif
BEGIN(symprio)
  RETURN(prio[symc]) ;
END  /* symprio */


                                                        /*-------------------*/
#ifdef LINT_ARGS
global void scaninit  ( void)
#else
global void scaninit ()                                 /*  s c a n i n i t  */
  /* initializes all constant arrays and sets of symc */
#endif
BEGIN (scaninit)
  short int i ;

  if  (cHighest >= 255)
     fprintf (stderr, "cHighest too big"), finish (-999) ;

                                                /*-----------------------*/
                                                /* Define priority table */
  prio [cNosym       ] = prioleaf     ;
  prio [cEndofSrc    ] = priobegin    ;

  prio [cPROGRAM     ] = prioleaf     ; /* unreserved keyword */
  prio [cMODULE      ] = prioleaf     ; /* " */
  prio [cPRIORITY    ] = priobegin    ;
  prio [cGLOBAL      ] = priobegin    ;
  prio [cUSE         ] = priostm      ;
  prio [cREALCONSTANTCONVERSION] = priobegin    ;
  prio [cLABEL       ] = priobegin    ;
  prio [cCONST       ] = priobegin    ;
  prio [cTYPE        ] = priobegin    ;
  prio [cPACKED      ] = priotypes    ;
  prio [cFILE        ] = priotypes    ;
  prio [cSET         ] = priotypes    ;
  prio [cRECORD      ] = priotypes    ;
  prio [cCASE        ] = priostm      ;
  prio [cDYNAMIC     ] = priotypes    ;
  prio [cARRAY       ] = priotypes    ;
  prio [cOF          ] = priostm      ;
  prio [cVAR         ] = priobegin    ;
  prio [cPROCEDURE   ] = priobegin    ;
  prio [cFUNCTION    ] = priobegin    ;
  prio [cOPERATOR    ] = priobegin    ;
  prio [cFORWARD     ] = prioleaf     ;
  prio [cEXTERNAL    ] = prioleaf     ;

  prio [cBEGIN       ] = priobegin    ;
  prio [cEND         ] = priostm      ;
  prio [cFOR         ] = prioleaf     ; /* "for" expression ! */
  prio [cTO          ] = priostm      ;
  prio [cDOWNTO      ] = priostm      ;
  prio [cDO          ] = priostm      ;
  prio [cSUM         ] = prioleaf     ; /* "for" expression ! */
  prio [cGOTO        ] = priostm      ;
  prio [cIF          ] = priostm      ;
  prio [cTHEN        ] = priostm      ;
  prio [cELSE        ] = priostm      ;
  prio [cREPEAT      ] = priostm      ;
  prio [cUNTIL       ] = priostm      ;
  prio [cWHILE       ] = priostm      ;
  prio [cWITH        ] = priostm      ;
  prio [cNew         ] = priostm      ;
  prio [cDispose     ] = priostm      ;
  prio [cNIL         ] = prioleaf     ;

  prio [cString      ] = priotypes    ;
  prio [cSizeof      ] = priomonop    ;
  prio [cSemicolon   ] = priosemicolon;
  prio [cColon       ] = priocolon    ;
  prio [cComma       ] = priocomma    ;
/*prio [cIoColon     ] = priocolon    ; */
  prio [cLParent     ] = priopar      ;
  prio [cRParent     ] = prioderef    ; /* cast Operator */
  prio [cPCast       ] = prioderef    ; /* cast Operator */
  prio [cLBrack      ] = prioindex    ;
  prio [cArrVar      ] = prioleaf     ; /* other priority than cLBrack */
  prio [cRBrack      ] = prioleaf     ; /* set constructor */

  prio [cLParD       ] = priovar      ;
  prio [cLParU       ] = priovar      ;
  prio [cDot         ] = priovar      ;
  prio [cDotN        ] = priovar      ;
  prio [cDotD        ] = priovar      ;
  prio [cDotU        ] = priovar      ;
  prio [cDotS        ] = priovar      ;
  prio [cTill        ] = priotill     ;
  prio [cPoint       ] = priovar      ;
  prio [cArrow       ] = prioderef    ; /* C priority */
  prio [cPArrow      ] = priovar      ;
  prio [cIrange      ] = prioleaf     ;
  prio [cAssign      ] = priostm      ;

  prio [cIN          ] = priorelop    ;
  prio [cEQ          ] = priorelop    ;
  prio [cNE          ] = priorelop    ;
  prio [cGE          ] = priorelop    ;
  prio [cGT          ] = priorelop    ;
  prio [cLE          ] = priorelop    ;
  prio [cLT          ] = priorelop    ;
/*prio [cStar        ] = priomulop    ; */
  prio [cPlus        ] = prioaddop    ;
  prio [cMinus       ] = prioaddop    ;
  prio [cMult        ] = priomulop    ;
  prio [cDiv         ] = priomulop    ;
  prio [cDisj        ] = priorelop    ;
  prio [cConj        ] = priomulop    ;
  prio [cCohu        ] = prioaddop    ;
  prio [cPlusD       ] = prioaddop    ;
  prio [cMinusD      ] = prioaddop    ;
  prio [cMultD       ] = priomulop    ;
  prio [cDivD        ] = priomulop    ;
  prio [cPlusU       ] = prioaddop    ;
  prio [cMinusU      ] = prioaddop    ;
  prio [cMultU       ] = priomulop    ;
  prio [cDivU        ] = priomulop    ;
  prio [cOR          ] = prioaddop    ;
  prio [cAND         ] = priomulop    ;
  prio [cDIV         ] = priomulop    ;
  prio [cMOD         ] = priomulop    ;
  prio [cMPlus       ] = priomonop    ;
  prio [cMMinus      ] = priomonop    ;
  prio [cAdres       ] = priomonop    ;
  prio [cNOT         ] = priomonop    ;

  prio [cReldmy      ] = priorelop    ;
  prio [cAdddmy      ] = prioaddop    ;
  prio [cMuldmy      ] = priomulop    ;
  prio [cRelop       ] = priorelop    ;
  prio [cAddop       ] = prioaddop    ;
  prio [cMulop       ] = priomulop    ;
  prio [cMonop       ] = priomonop    ;

  for (i = cIcon; i <= cBcon; i++)    /* constants */
    prio [i] = prioleaf ;

  prio [cOpptr       ] = prioleaf     ;
  prio [cBlkptr      ] = priobegin    ;

  prio [cUntemp      ] = priostm      ;
  prio [cFree        ] = priostm      ;

  prio [cCsymbol     ] = prioleaf     ;
  prio [cTemptype    ] = priotypes    ;
  prio [cRecelem     ] = prioleaf     ;
  prio [cTempused    ] = prioleaf     ;
  prio [cTempvar     ] = prioleaf     ;
  prio [cRegister    ] = prioleaf     ;
  prio [cArrsym      ] = priovar      ;
  prio [cCall        ] = prioleaf     ;
  prio [cVarparam    ] = priosemicolon;
  prio [cIdlist      ] = priocomma    ;
  prio [cRout        ] = prioleaf     ;
  prio [cArry        ] = priovar      ;
  for (i = cIdent; i <= cHighest; i++)  /* identifiers */
    prio [i] = prioleaf ;

  (void) memcpy (cprio, prio, cHighest*sizeof(short int)) ;
  cprio [cFOR         ] = priostm      ;
  cprio [cAssign      ] = prioass      ;
  cprio [cOR          ] = prio_orop    ;
  cprio [cAND         ] = prioandop    ;

                                                /* priority table defined */
                                                /*------------------------*/

                                                /*--------------------*/
                                                /* define symbol sets */
  for (i = cNosym; i <= cHighest; i++)
     sym_is[i].list = false ;                   /* set of list nodes */
  sym_is[cSemicolon].list = true ;
  sym_is[cVarparam ].list = true ;
  sym_is[cIdlist   ].list = true ;
  sym_is[cComma    ].list = true ;
  sym_is[cRecelem  ].list = true ;
  sym_is[cCsymbol  ].list = true ;

  for (i = cNosym; i <= cVarparam; i++)         /* set of identifiers */
     sym_is[i].identifier = false ;             /*  pointing to idtab */
  sym_is[cEXTERNAL ].identifier = true ;
  sym_is[cFORWARD  ].identifier = true ;
  for (i = cVarparam; i <= cHighest; i++)
     sym_is[i].identifier = true ;

  for (i = cNosym; i <= cHighest; i++)
     sym_is[i].variable = sym_is[i].identifier ; /* set of variables */
  sym_is[cArrow    ].variable = true ;
  sym_is[cPArrow   ].variable = true ;
  sym_is[cPoint    ].variable = true ;
  sym_is[cArry     ].variable = true ;
  sym_is[cArrVar   ].variable = true ;

  for (i = cNosym; i <= cHighest; i++)
     sym_is[i].lvalue = false ;                  /* set of C variables */
  sym_is[cCsymbol  ].lvalue   = true ;
  sym_is[cTempused ].lvalue   = true ;
  sym_is[cTempvar  ].lvalue   = true ;
  sym_is[cRegister ].lvalue   = true ;
  sym_is[cArrsym   ].lvalue   = true ;

  for (i = cNosym; i <= cHighest; i++)          /* set of symbols */
     sym_is[i].symbol = false ;                 /*  pointing to symtab */
  sym_is[cRelop    ].symbol   = true ;
  sym_is[cAddop    ].symbol   = true ;
  sym_is[cMulop    ].symbol   = true ;
  sym_is[cMonop    ].symbol   = true ;
  for (i = cCsymbol; i <= cCall; i++)           /* set of symbols */
     sym_is[i].symbol = true  ;                 /*  pointing to symtab */
  sym_is[cUSE      ].symbol   = true ;
  sym_is[cGLOBAL   ].symbol   = true ;

  for (i = cNosym; i <= cHighest; i++)
     sym_is[i].constant = false ;
  for (i = cIcon; i <= cBcon; i++)
     sym_is[i].constant = true ;                 /* set of constant */

  for (i = cNosym; i <= cHighest; i++)
     sym_is[i].operand = sym_is[i].constant or
                         sym_is[i].identifier ;  /* set of operands to be */
  sym_is[cNIL      ].operand = true ;            /*   appended            */
  sym_is[cRBrack   ].operand = true ;            /* or set constructor */
  sym_is[cCall     ].operand = true ;
  sym_is[cRout     ].operand = true ;
  sym_is[cIrange   ].operand = true ;

  for (i = cNosym; i <= cHighest; i++)
     sym_is[i].type = sym_is[i].identifier ;  /* set of type starters */
  sym_is[cPACKED   ].type    = true ;
  sym_is[cFILE     ].type    = true ;
  sym_is[cSET      ].type    = true ;
  sym_is[cRECORD   ].type    = true ;
  sym_is[cARRAY    ].type    = true ;
  sym_is[cDYNAMIC  ].type    = true ;
  sym_is[cArrow    ].type    = true ;
/*  sym_is[cLParent  ].type    = true ;  no enumeration type */
  sym_is[cTemptype ].type    = true ;

  for (i = cNosym; i <  cRelop ; i++)           /* set of userdefinable */
     sym_is[i].userdefined = false ;              /*  symbols */
  sym_is[cEXTERNAL ].userdefined = true ;
  sym_is[cFORWARD  ].userdefined = true ;
  sym_is[cUSE      ].userdefined = true ;
  sym_is[cGLOBAL   ].userdefined = true ;
  for (i = cRelop ; i <= cHighest; i++)
     sym_is[i].userdefined = true ;
  sym_is[cUntemp   ].userdefined = false ;
  sym_is[cFree     ].userdefined = false ;

  for (i = cNosym; i <  cIN     ; i++)
     sym_is[i].Operator = false ;
  sym_is[cSizeof   ].Operator = true ;
  for (i = cIN   ; i <= cMonop  ; i++)          /* set of Operators */
     sym_is[i].Operator = true  ;
  for (i = cIcon ; i <= cHighest; i++)
     sym_is[i].Operator = false ;

  for (i = cNosym; i <= cHighest; i++)
     sym_is[i].statement = false ;
  sym_is[cBEGIN    ].statement = true ;         /* set of statement */
  sym_is[cFOR      ].statement = true ;         /*        keywords  */
  sym_is[cGOTO     ].statement = true ;
  sym_is[cIF       ].statement = true ;
  sym_is[cCASE     ].statement = true ;
  sym_is[cREPEAT   ].statement = true ;
  sym_is[cWHILE    ].statement = true ;
  sym_is[cWITH     ].statement = true ;
  sym_is[cUntemp   ].statement = true ;
  sym_is[cFree     ].statement = true ;

  for (i = cNosym; i <= cHighest; i++)
     sym_is[i].std_procdre = false ;
  sym_is[cREAD     ].std_procdre = true ;       /* set of standard routines */
  sym_is[cREADLN   ].std_procdre = true ;       /*  used by errecy  */
  sym_is[cWRITE    ].std_procdre = true ;
  sym_is[cWRITELN  ].std_procdre = true ;
  sym_is[cALLOCATE ].std_procdre = true ;

  for (i = cNosym; i <= cHighest; i++)
     sym_is[i].stmstopper = sym_is[i].statement ;
  sym_is[cSemicolon].stmstopper = true ;        /* set of symbols    */
  sym_is[cEND      ].stmstopper = true ;        /* ending of statements */
  sym_is[cELSE     ].stmstopper = true ;
  sym_is[cUNTIL    ].stmstopper = true ;
  sym_is[cEndofSrc ].stmstopper = true ;

  for (i = cNosym; i <= cHighest; i++)
    sym_is[i].leaf = false ;                    /* set of leaves */
  sym_is[cIrange   ].leaf = true ;              /*  have no left and */
  sym_is[cNIL      ].leaf = true ;              /*  no right pointer */
  for (i = cIcon ; i <= cBcon   ; i++)
    sym_is[i].leaf = true ;                     /* set of leaves */

  for (i = cNosym; i <= cHighest; i++)          /* set of nodes having */
    sym_is[i].leftbin = not ( sym_is[i].userdefined) ;     /* left son */
  sym_is[cNosym    ].leftbin = true ;
  sym_is[cNOT      ].leftbin = false ;
  sym_is[cMPlus    ].leftbin = false ;
  sym_is[cMMinus   ].leftbin = false ;
  sym_is[cSizeof   ].leftbin = false ;
  sym_is[cNIL      ].leftbin = false ;
  sym_is[cIrange   ].leftbin = false ;
  for (i = cLParD; i <= cDotS  ; i++)
     sym_is[i].leftbin  = false ;

  for (i = cNosym; i <= cHighest; i++)          /* set of nodes having */
    sym_is[i].rightbin = true ;                      /* right son */
          /* previously: not ( sym_is[i].constant) ; */
  sym_is[cNosym    ].rightbin = true ;
  sym_is[cNIL      ].rightbin = true ;     /* all nodes may have right son */
  sym_is[cIrange   ].rightbin = true ;

  for (i = cNosym; i <= cHighest; i++)          /* set of nodes having */
    sym_is[i].leftexpr = sym_is[i].leftbin ;    /* no-data-type left son */
  sym_is[cRParent  ].leftexpr = false ;         /* used by bintdelete */
  sym_is[cPCast    ].leftexpr = false ;
  sym_is[cVAR      ].leftexpr = false ;
  sym_is[cTYPE     ].leftexpr = false ;
  sym_is[cNew      ].leftexpr = false ;
  sym_is[cDispose  ].leftexpr = false ;

  for (i = cNosym; i <= cHighest; i++)          /* set of nodes having */
    sym_is[i].rightexpr = sym_is[i].rightbin ;  /* no-data-type right son */
  sym_is[cCsymbol  ].rightexpr = false ;        /* used by bintdelete */
  sym_is[cTempvar  ].rightexpr = false ;
  sym_is[cTempused ].rightexpr = false ;
  sym_is[cTemptype ].rightexpr = false ;
  sym_is[cRecelem  ].rightexpr = false ;
  sym_is[cRegister ].rightexpr = false ;
  sym_is[cNosym    ].rightexpr = false ;

  for (i = cNosym; i <= cHighest; i++)
     sym_is[i].value = false ;                  /* set of nodes having */
  sym_is[cIcon].value = true ;                        /* integer value */
  sym_is[cCcon].value = true ;
  sym_is[cBcon].value = true ;
/*sym_is[cS2con].value = true ;
  sym_is[cS3con].value = true ;
  sym_is[cS4con].value = true ; */

  for (i = cNosym; i <= cHighest; i++)          /* set of C names to */
     sym_is[i].rename = false ;                 /*        be renamed */
  sym_is[cNULL  ].rename = true ;
  sym_is[cEOF   ].rename = true ;
  sym_is[cBUFSIZ].rename = true ;

  for (i = cNosym; i <= cHighest; i++)          /* set of index or   */
     sym_is[i].scalartype = false ;             /* scalar data type: */
  sym_is[cTill   ].scalartype = true ;          /* subrange */
  sym_is[cLParent].scalartype = true ;          /* enumeration */
  sym_is[cNosym  ].scalartype = true ;          /* any type */
  sym_is[cBOOLEAN].scalartype = true ;
  sym_is[cCHAR   ].scalartype = true ;
  sym_is[cINTEGER].scalartype = true ;

  for (i = cNosym; i <= cHighest; i++)          /* set of    */
     sym_is[i].arraytype = false ;              /*  array data types */
  sym_is[cARRAY  ].arraytype = true ;
  sym_is[cScon   ].arraytype = true ;
  sym_is[cSET    ].arraytype = true ;

                                                /* symbol sets defined */
                                                /*---------------------*/

  symkeyword (cSUM    , true) ; /* switch SUM to keyword */ /* neaga */

                                            /*------------------------------*/
                                            /* define Pascal representation */
  symptext[ cNosym    ] = "unknown" ;
  symptext[ cEndofSrc ] = "end of source" ;

  symptext[ cPROGRAM  ] = "PROGRAM" ;
  symptext[ cMODULE   ] = "MODULE" ;
  symptext[ cPRIORITY ] = "PRIORITY" ;
  symptext[ cGLOBAL   ] = "GLOBAL" ;
  symptext[ cUSE      ] = "USE" ;
  symptext[ cREALCONSTANTCONVERSION] = "REALCONSTANTCONVERSION" ;
  symptext[ cLABEL    ] = "LABEL" ;
  symptext[ cCONST    ] = "CONST" ;
  symptext[ cTYPE     ] = "TYPE" ;
  symptext[ cPACKED   ] = "PACKED" ;
  symptext[ cFILE     ] = "FILE" ;
  symptext[ cSET      ] = "SET" ;
  symptext[ cRECORD   ] = "RECORD" ;
  symptext[ cCASE     ] = "CASE" ;
  symptext[ cDYNAMIC  ] = "DYNAMIC" ;
  symptext[ cARRAY    ] = "ARRAY" ;
  symptext[ cOF       ] = "OF" ;
  symptext[ cVAR      ] = "VAR" ;
  symptext[ cPROCEDURE] = "PROCEDURE" ;
  symptext[ cFUNCTION ] = "FUNCTION" ;
  symptext[ cOPERATOR ] = "OPERATOR" ;
  symptext[ cFORWARD  ] = "FORWARD" ;
  symptext[ cEXTERNAL ] = "EXTERNAL" ;

  symptext[ cBEGIN    ] = "BEGIN" ;
  symptext[ cEND      ] = "END" ;
  symptext[ cFOR      ] = "FOR" ;
  symptext[ cTO       ] = "TO" ;
  symptext[ cDOWNTO   ] = "DOWNTO" ;
  symptext[ cDO       ] = "DO" ;
  symptext[ cSUM      ] = "SUM" ;
  symptext[ cGOTO     ] = "GOTO" ;
  symptext[ cIF       ] = "IF" ;
  symptext[ cTHEN     ] = "THEN" ;
  symptext[ cELSE     ] = "ELSE" ;
  symptext[ cREPEAT   ] = "REPEAT" ;
  symptext[ cUNTIL    ] = "UNTIL" ;
  symptext[ cWHILE    ] = "WHILE" ;
  symptext[ cWITH     ] = "WITH" ;
  symptext[ cNew      ] = "New" ;
  symptext[ cDispose  ] = "Dispose" ;
  symptext[ cNIL      ] = "NIL" ;

  symptext[ cString   ] = "STRING" ;
  symptext[ cSizeof   ] = "sizeof" ;
  symptext[ cSemicolon] = ";" ;
  symptext[ cColon    ] = ":" ;
  symptext[ cComma    ] = "," ;
  symptext[ cLParent  ] = "(" ;
  symptext[ cRParent  ] = ")" ;
  symptext[ cPCast    ] = "PCast" ;

/* PJ 31.07.92 */

#ifdef NOBRACKETS
  symptext[ cLBrack   ] = "??(";
#else
  symptext[ cLBrack   ] = "[" ;
/*symptext[ cLBrack   ] = "(." ; */
#endif
#ifdef NOBRACKETS
  symptext[ cArrVar   ] = "??(";
#else
  symptext[ cArrVar   ] = "[" ;
/*symptext[ cArrVar   ] = "(." ; */
#endif
#ifdef NOBRACKETS
  symptext[ cRBrack   ] = "??)";
#else
  symptext[ cRBrack   ] = "]" ;
/*symptext[ cRBrack   ] = ".)" ; */
#endif

/* END PJ 31.07.92 */

  symptext[ cLParD    ] = "(<" ;
  symptext[ cLParU    ] = "(>" ;
  symptext[ cDot      ] = "#" ;
  symptext[ cDotN     ] = "#*" ;
  symptext[ cDotD     ] = "#<" ;
  symptext[ cDotU     ] = "#>" ;
  symptext[ cDotS     ] = "##" ;
  symptext[ cTill     ] = ".." ;
  symptext[ cPoint    ] = "." ;

/* PJ 31.07.92 */

#ifdef NOBRACKETS
  symptext[ cArrow    ] = "??'";
#else
  symptext[ cArrow    ] = "^" ;
/*symptext[ cArrow    ] = "@" ; */
#endif
#ifdef NOBRACKETS
  symptext[ cPArrow   ] = "??'.";
#else
  symptext[ cPArrow   ] = "^." ;
/*symptext[ cPArrow   ] = "@." ; */
#endif

/* END PJ 31.07.92 */

  symptext[ cIrange   ] = "$*" ;
  symptext[ cAssign   ] = ":=" ;

  symptext[ cIN       ] = "IN" ;
  symptext[ cEQ       ] = "=" ;
  symptext[ cNE       ] = "<>" ;
  symptext[ cGE       ] = ">=" ;
  symptext[ cGT       ] = ">" ;
  symptext[ cLE       ] = "<=" ;
  symptext[ cLT       ] = "<" ;
/*symptext[ cStar     ] = "$*" ; */
  symptext[ cPlus     ] = "+" ;
  symptext[ cMinus    ] = "-" ;
  symptext[ cMult     ] = "*" ;
  symptext[ cDiv      ] = "/" ;
  symptext[ cDisj     ] = "><" ;
  symptext[ cConj     ] = "**" ;
  symptext[ cCohu     ] = "+*" ;
  symptext[ cPlusD    ] = "+<" ;
  symptext[ cMinusD   ] = "-<" ;
  symptext[ cMultD    ] = "*<" ;
  symptext[ cDivD     ] = "/<" ;
  symptext[ cPlusU    ] = "+>" ;
  symptext[ cMinusU   ] = "->" ;
  symptext[ cMultU    ] = "*>" ;
  symptext[ cDivU     ] = "/>" ;
  symptext[ cOR       ] = "OR" ;
  symptext[ cAND      ] = "AND" ;
  symptext[ cDIV      ] = "DIV" ;
  symptext[ cMOD      ] = "MOD" ;
  symptext[ cMPlus    ] = "  +" ;
  symptext[ cMMinus   ] = "  -" ;
  symptext[ cAdres    ] = "&" ;
  symptext[ cNOT      ] = "NOT" ;

  symptext[ cReldmy   ] = "cReldmy" ;
  symptext[ cAdddmy   ] = "cAdddmy" ;
  symptext[ cMuldmy   ] = "cMuldmy" ;
  symptext[ cRelop    ] = "cRelop" ;
  symptext[ cAddop    ] = "cAddop" ;
  symptext[ cMulop    ] = "cMulop" ;
  symptext[ cMonop    ] = "cMonop" ;

  symptext[ cIcon     ] = "integer constant" ;
  symptext[ cCcon     ] = "char constant" ;
  symptext[ cScon     ] = "string constant" ;
/*symptext[ cS2con    ] = "cS2con" ; */
/*symptext[ cS3con    ] = "cS3con" ; */
/*symptext[ cS4con    ] = "cS4con" ; */
  symptext[ cRcon     ] = "real constant" ;
  symptext[ cBcon     ] = "boolean constant" ;

  symptext[ cOpptr    ] = "cOpptr" ;
  symptext[ cBlkptr   ] = "cBlkptr" ;

  symptext[ cUntemp   ] = "cUntemp" ;
  symptext[ cFree     ] = "cFree" ;

  symptext[ cCsymbol  ] = "cCsymbol" ;
  symptext[ cTemptype ] = "cTemptype" ;
  symptext[ cRecelem  ] = "cRecelem" ;
  symptext[ cTempused ] = "cTempused" ;
  symptext[ cTempvar  ] = "cTempvar" ;
  symptext[ cRegister ] = "cRegister" ;
  symptext[ cArrsym   ] = "cArrsym" ;
  symptext[ cCall     ] = "cCall" ;
  symptext[ cVarparam ] = "cVarparam" ;
  symptext[ cIdlist   ] = "cIdlist" ;
  symptext[ cRout     ] = "cRout" ;
  symptext[ cArry     ] = "cArry" ;
  symptext[ cIdent    ] = "Identifier" ;

  symptext[ cFALSE    ] = "FALSE" ;
  symptext[ cTRUE     ] = "TRUE" ;
  symptext[ cMAXINT   ] = "MAXINT" ;
  symptext[ cBOOLEAN  ] = "BOOLEAN" ;
  symptext[ cCHAR     ] = "CHAR" ;
  symptext[ cINTEGER  ] = "INTEGER" ;
  symptext[ cREAL     ] = "REAL" ;
  symptext[ cTEXT     ] = "TEXT" ;
  symptext[ cDOTPRECISION] = "DOTPRECISION" ;
  symptext[ cIDOTPRECISION] = "IDOTPRECISION" ;
  symptext[ cCDOTPRECISION] = "CDOTPRECISION" ;
  symptext[ cCIDOTPRECISION] = "CIDOTPRECISION" ;
  symptext[ cSTRING   ] = "STRING" ;
  symptext[ cINPUT    ] = "INPUT" ;
  symptext[ cOUTPUT   ] = "OUTPUT" ;
  symptext[ cLBOUND   ] = "LBOUND" ;
  symptext[ cLB       ] = "LB" ;
  symptext[ cUBOUND   ] = "UBOUND" ;
  symptext[ cUB       ] = "UB" ;
  symptext[ cSUCC     ] = "SUCC" ;
  symptext[ cPRED     ] = "PRED" ;
  symptext[ cCHR      ] = "CHR" ;
  symptext[ cORD      ] = "ORD" ;
  symptext[ cROUND    ] = "ROUND" ;
  symptext[ cTRUNC    ] = "TRUNC" ;
  symptext[ cODD      ] = "ODD" ;
  symptext[ cLENGTH   ] = "LENGTH" ;
  symptext[ cMAXLENGTH] = "MAXLENGTH" ;
  symptext[ cPOS      ] = "POS" ;
  symptext[ cSUBSTRING] = "SUBSTRING" ;
  symptext[ cSCALP    ] = "SCALP" ;
  symptext[ cEOF      ] = "EOF" ;
  symptext[ cEOLN     ] = "EOLN" ;
  symptext[ cRESET    ] = "RESET" ;
  symptext[ cREWRITE  ] = "REWRITE" ;
  symptext[ cGET      ] = "GET" ;
  symptext[ cPUT      ] = "PUT" ;
  symptext[ cREAD     ] = "READ" ;
  symptext[ cREADLN   ] = "READLN" ;
  symptext[ cWRITE    ] = "WRITE" ;
  symptext[ cWRITELN  ] = "WRITELN" ;
  symptext[ cPAGE     ] = "PAGE" ;
  symptext[ cIMAGE    ] = "IMAGE" ;
  symptext[ cPACK     ] = "PACK" ;
  symptext[ cUNPACK   ] = "UNPACK" ;
  symptext[ cNEW      ] = "NEW" ;
  symptext[ cDISPOSE  ] = "DISPOSE" ;
  symptext[ cALLOCATE ] = "ALLOCATE";
  symptext[ cFREE     ] = "FREE";
  symptext[ cALLOCATED] = "ALLOCATED";

  symptext[ cABS      ] = "ABS" ;
  symptext[ cARCTAN   ] = "ARCTAN" ;
  symptext[ cCINTERVAL] = "CINTERVAL" ;
  symptext[ cCOMPLEX  ] = "COMPLEX" ;
  symptext[ cCOS      ] = "COS" ;
  symptext[ cEXP      ] = "EXP" ;
  symptext[ cIM       ] = "IM" ;
  symptext[ cINF      ] = "INF" ;
  symptext[ cINTERVAL ] = "INTERVAL" ;
  symptext[ cIVAL     ] = "IVAL" ;
  symptext[ cLN       ] = "LN" ;
  symptext[ cRE       ] = "RE" ;
  symptext[ cRVAL     ] = "RVAL" ;
  symptext[ cSIN      ] = "SIN" ;
  symptext[ cSQR      ] = "SQR" ;
  symptext[ cSQRT     ] = "SQRT" ;
  symptext[ cSUP      ] = "SUP" ;
  symptext[ cRVECTOR  ] = "RVECTOR" ;
  symptext[ cCVECTOR  ] = "CVECTOR" ;
  symptext[ cIVECTOR  ] = "IVECTOR" ;
  symptext[ cCIVECTOR ] = "CIVECTOR" ;
  symptext[ cRMATRIX  ] = "RMATRIX" ;
  symptext[ cCMATRIX  ] = "CMATRIX" ;
  symptext[ cIMATRIX  ] = "IMATRIX" ;
  symptext[ cCIMATRIX ] = "CIMATRIX" ;
  symptext[ cINTVAL   ] = "INTVAL" ;
  symptext[ cCOMPL    ] = "COMPL" ;
  symptext[ cNULL     ] = "NULL" ;
  symptext[ cID       ] = "ID" ;
  symptext[ cCONJ     ] = "CONJ" ;
  symptext[ cTRANSP   ] = "TRANSP" ;
  symptext[ cHERM     ] = "HERM" ;
  symptext[ cBUFSIZ   ] = "BUFSIZ" ;
  symptext[ cPTRCHAR  ] = "PTRCHAR" ;
  symptext[ cSIZEOF   ] = "SIZEOF" ;
  symptext[ cINT_OF_C ] = "INT_OF_C" ;
  symptext[ cFILE_OF_C] = "FILE_OF_C" ;
  symptext[ cPOINTER_OF_C ] = "POINTER_OF_C" ;

  symptext[ cHighest  ] = "$Highest" ;
                                            /* Pascal representation defined */
                                            /*-------------------------------*/

                                               /*-------------------------*/
                                               /* define C representation */
  symctext[ cNosym    ] = "$Nosym" ;
  symctext[ cEndofSrc ] = "$EndofSrc" ;

  symctext[ cPROGRAM  ] = "  " ;
  symctext[ cMODULE   ] = "  " ;
  symctext[ cPRIORITY ] = "  " ;
  symctext[ cGLOBAL   ] = "  " ;
  symctext[ cUSE      ] = "  " ;
  symctext[ cREALCONSTANTCONVERSION] = "  " ;
  symctext[ cLABEL    ] = "  " ;
  symctext[ cCONST    ] = "#define " ;
  symctext[ cTYPE     ] = "typedef " ;
  symctext[ cPACKED   ] = "  " ;
  symctext[ cFILE     ] = "f_ilof" ;
  symctext[ cSET      ] = "  " ;
  symctext[ cRECORD   ] = "struct " ;
  symctext[ cCASE     ] = "switch" ;
  symctext[ cDYNAMIC  ] = "y_arof" ;
  symctext[ cARRAY    ] = "" ;
  symctext[ cOF       ] = "  " ;
  symctext[ cVAR      ] = "" ;
  symctext[ cPROCEDURE] = "  " ;
  symctext[ cFUNCTION ] = "  " ;
  symctext[ cOPERATOR ] = "  " ;
  symctext[ cFORWARD  ] = "  " ;
  symctext[ cEXTERNAL ] = "  " ;

  symctext[ cBEGIN    ] = "{" ;
  symctext[ cEND      ] = "}" ;
  symctext[ cFOR      ] = "for" ;
  symctext[ cTO       ] = "" ;
  symctext[ cDOWNTO   ] = "" ;
  symctext[ cDO       ] = "" ;
  symctext[ cSUM      ] = "  " ;
  symctext[ cGOTO     ] = "  " ;
  symctext[ cIF       ] = "if" ;
  symctext[ cTHEN     ] = "" ;
  symctext[ cELSE     ] = "else " ;
  symctext[ cREPEAT   ] = "do " ;
  symctext[ cUNTIL    ] = "  " ;
  symctext[ cWHILE    ] = "while" ;
  symctext[ cWITH     ] = "" ;
  symctext[ cNew      ] = "malloc" ;
  symctext[ cDispose  ] = "free" ;
  symctext[ cNIL      ] = "0" ;  /* NULL */

  symctext[ cString   ] = "char " ;
  symctext[ cSizeof   ] = "sizeof" ;
  symctext[ cSemicolon] = ";" ;
  symctext[ cColon    ] = ":" ;
  symctext[ cComma    ] = "," ;
  symctext[ cLParent  ] = "(" ;
  symctext[ cRParent  ] = ")" ;
  symctext[ cPCast    ] = "*)" ;
#ifdef NOBRACKETS
  symctext[ cLBrack   ] = "?\?(" ;
  symctext[ cArrVar   ] = "?\?(" ;
  symctext[ cRBrack   ] = "?\?)" ;
#else
  symctext[ cLBrack   ] = "[" ;
  symctext[ cArrVar   ] = "[" ;
  symctext[ cRBrack   ] = "]" ;
#endif

  symctext[ cLParU    ] = " " ;
  symctext[ cLParD    ] = " " ;
  symctext[ cDot      ] = " " ;
  symctext[ cDotN     ] = " " ;
  symctext[ cDotD     ] = " " ;
  symctext[ cDotU     ] = " " ;
  symctext[ cDotS     ] = " " ;
  symctext[ cTill     ] = " " ;
  symctext[ cPoint    ] = "." ;
  symctext[ cArrow    ] = "*" ;
  symctext[ cPArrow   ] = "->" ;
  symctext[ cIrange   ] = "$*" ;
  symctext[ cAssign   ] = "=" ;

  symctext[ cIN       ] = "  " ;
  symctext[ cEQ       ] = "==" ;
  symctext[ cNE       ] = "!=" ;
  symctext[ cGE       ] = ">=" ;
  symctext[ cGT       ] = ">" ;
  symctext[ cLE       ] = "<=" ;
  symctext[ cLT       ] = "<" ;
/*symctext[ cStar     ] = "  " ; */
  symctext[ cPlus     ] = "+" ;
  symctext[ cMinus    ] = "-" ;
  symctext[ cMult     ] = "*" ;
  symctext[ cDiv      ] = "/" ;
  symctext[ cDisj     ] = "  " ;
  symctext[ cConj     ] = "  " ;
  symctext[ cCohu     ] = "  " ;
  symctext[ cPlusD    ] = "  " ;
  symctext[ cMinusD   ] = "  " ;
  symctext[ cMultD    ] = "  " ;
  symctext[ cDivD     ] = "  " ;
  symctext[ cPlusU    ] = "  " ;
  symctext[ cMinusU   ] = "  " ;
  symctext[ cMultU    ] = "  " ;
  symctext[ cDivU     ] = "  " ;
  symctext[ cOR       ] = "||" ;
  symctext[ cAND      ] = "&&" ;
  symctext[ cDIV      ] = "/" ;
  symctext[ cMOD      ] = "%" ;
  symctext[ cMPlus    ] = "" ;
  symctext[ cMMinus   ] = "-" ;
  symctext[ cAdres    ] = "&" ;
  symctext[ cNOT      ] = "!" ;

  symctext[ cReldmy   ] = "$Reldmy?" ;
  symctext[ cAdddmy   ] = "$Adddmy?" ;
  symctext[ cMuldmy   ] = "$Muldmy?" ;
  symctext[ cRelop    ] = "$Relop?" ;
  symctext[ cAddop    ] = "$Addop?" ;
  symctext[ cMulop    ] = "$Mulop?" ;
  symctext[ cMonop    ] = "$Monop?" ;

  symctext[ cIcon     ] = "$Icon?" ;
  symctext[ cCcon     ] = "$Ccon?" ;
  symctext[ cScon     ] = "$Scon?" ;
/*symctext[ cS2con    ] = "$S2con?" ; */
/*symctext[ cS3con    ] = "$S3con?" ; */
/*symctext[ cS4con    ] = "$S4con?" ; */
  symctext[ cRcon     ] = "$Rcon?" ;
  symctext[ cBcon     ] = "$Bcon?" ;

  symctext[ cOpptr    ] = "$Opptr?" ;
  symctext[ cBlkptr   ] = "$Blkptr?" ;

  symctext[ cUntemp   ] = "?_utmp" ;
  symctext[ cFree     ] = "?_free" ;

  symctext[ cCsymbol  ] = "$Csymbol?" ;
  symptext[ cTemptype ] = "$Temptype?" ;
  symptext[ cRecelem  ] = "$Recelem?" ;
  symptext[ cTempused ] = "$Tempused?" ;
  symctext[ cTempvar  ] = "$Tempvar" ;
  symctext[ cRegister ] = "$Register" ;
  symctext[ cArrsym   ] = "$Arrsym" ;
  symctext[ cCall     ] = "$(" ;
  symctext[ cVarparam ] = "$;" ;
  symctext[ cIdlist   ] = "$," ;
  symctext[ cRout     ] = "$(" ;
  symctext[ cArry     ] = "$[" ;
  symctext[ cIdent    ] = "$Ident" ;

  symctext[ cFALSE    ] = "0" ;
  symctext[ cTRUE     ] = "1" ;
  symctext[ cMAXINT   ] = " " ;
  symctext[ cBOOLEAN  ] = "a_bool" ;
  symctext[ cCHAR     ] = "a_char" ;
  symctext[ cINTEGER  ] = "a_intg" ;
  symctext[ cREAL     ] = "a_real" ;
  symctext[ cTEXT     ] = " " ;
  symctext[ cDOTPRECISION] = " " ;
  symctext[ cIDOTPRECISION] = " " ;
  symctext[ cCDOTPRECISION] = " " ;
  symctext[ cCIDOTPRECISION] = " " ;
  symctext[ cSTRING   ] = "s_trng" ;
  symctext[ cINPUT    ] = "f_inpu" ;
  symctext[ cOUTPUT   ] = "f_outp" ;
  symctext[ cLBOUND   ] = " " ;
  symctext[ cLB       ] = " " ;
  symctext[ cUBOUND   ] = " " ;
  symctext[ cUB       ] = " " ;
  symctext[ cSUCC     ] = "++" ;
  symctext[ cPRED     ] = "--" ;
  symctext[ cCHR      ] = "" ;
  symctext[ cORD      ] = "" ;
  symctext[ cROUND    ] = " " ;
  symctext[ cTRUNC    ] = " " ;
  symctext[ cODD      ] = "1&" ;
  symctext[ cLENGTH   ] = "strlen" ;
  symctext[ cMAXLENGTH] = " " ;
  symctext[ cPOS      ] = " " ;
  symctext[ cSUBSTRING] = " " ;
  symctext[ cSCALP    ] = " " ;
  symctext[ cEOF      ] = "EOF" ;
  symctext[ cEOLN     ] = "\n" ;
  symctext[ cRESET    ] = " " ;
  symctext[ cREWRITE  ] = " " ;
  symctext[ cGET      ] = " " ;
  symctext[ cPUT      ] = " " ;
  symctext[ cREAD     ] = "scanf" ;
  symctext[ cREADLN   ] = " " ;
  symctext[ cWRITE    ] = "printf" ;
  symctext[ cWRITELN  ] = " " ;
  symctext[ cPAGE     ] = " " ;
  symctext[ cIMAGE    ] = " " ;
  symctext[ cPACK     ] = " " ;
  symctext[ cUNPACK   ] = " " ;
  symctext[ cNEW      ] = "malloc" ;
  symctext[ cDISPOSE  ] = "free" ;
  symctext[ cALLOCATE ] = " " ;
  symctext[ cFREE     ] = " " ;
  symctext[ cALLOCATED] = " " ;

  symctext[ cABS      ] = " " ;
  symctext[ cARCTAN   ] = " " ;
  symctext[ cCINTERVAL] = " " ;
  symctext[ cCOMPLEX  ] = " " ;
  symctext[ cCOS      ] = " " ;
  symctext[ cEXP      ] = " " ;
  symctext[ cIM       ] = " " ;
  symctext[ cINF      ] = " " ;
  symctext[ cINTERVAL ] = " " ;
  symctext[ cIVAL     ] = " " ;
  symctext[ cLN       ] = " " ;
  symctext[ cRE       ] = " " ;
  symctext[ cRVAL     ] = " " ;
  symctext[ cSIN      ] = " " ;
  symctext[ cSQR      ] = " " ;
  symctext[ cSQRT     ] = " " ;
  symctext[ cSUP      ] = " " ;
  symctext[ cRVECTOR  ] = " " ;
  symctext[ cCVECTOR  ] = " " ;
  symctext[ cIVECTOR  ] = " " ;
  symctext[ cCIVECTOR ] = " " ;
  symctext[ cRMATRIX  ] = " " ;
  symctext[ cCMATRIX  ] = " " ;
  symctext[ cIMATRIX  ] = " " ;
  symctext[ cCIMATRIX ] = " " ;
  symctext[ cINTVAL   ] = " " ;
  symctext[ cCOMPL    ] = " " ;
  symctext[ cNULL     ] = " " ;
  symctext[ cID       ] = " " ;
  symctext[ cCONJ     ] = " " ;
  symctext[ cTRANSP   ] = " " ;
  symctext[ cHERM     ] = " " ;
  symctext[ cBUFSIZ   ] = " " ;
  symctext[ cPTRCHAR  ] = "char*" ;
  symctext[ cSIZEOF   ] = "sizeof" ;
  symctext[ cINT_OF_C ] = "int" ;
  symctext[ cFILE_OF_C] = "FILE*" ;
  symctext[ cPOINTER_OF_C ] = "a_VOID" ;

  symctext[ cHighest  ] = "$Highest" ;
                                                /* C  representation defined */
                                                /*---------------------------*/
END /* scaninit */

