home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Trees / V7 / usr / src / cmd / c / c05.c < prev    next >
Encoding:
C/C++ Source or Header  |  1979-01-10  |  4.4 KB  |  185 lines

  1. #
  2. #include "c0.h"
  3. /*
  4.  *  info on operators:
  5.  *   01-- is binary operator
  6.  *   02-- left (or only) operand must be lvalue
  7.  *   04-- is relational operator
  8.  *  010-- is assignment-type operator
  9.  *  020-- non-float req. on left
  10.  *  040-- non-float req. on right
  11.  * 0100-- is commutative
  12.  * 0200-- is right, not left-associative
  13.  * 0400-- is leaf of tree
  14.  * *0XX000-- XX is priority of operator
  15.  */
  16. int opdope[] {
  17.     000000,    /* EOFC */
  18.     000000,    /* ; */
  19.     000000,    /* { */
  20.     000000,    /* } */
  21.     036000,    /* [ */
  22.     002000,    /* ] */
  23.     037000,    /* ( */
  24.     002000,    /* ) */
  25.     014201,    /* : */
  26.     007001,    /* , */
  27.     000001,    /* field selection */
  28.     034201,    /* CAST */
  29.     000000,    /* ETYPE */
  30.     000001,    /* integer->ptr */
  31.     000001,    /* ptr->integer */
  32.     000001,    /* long->ptr */
  33.     000000,    /* 16 */
  34.     000000,    /* 17 */
  35.     000000,    /* 18 */
  36.     000000,    /* 19 */
  37.     000400,    /* name */
  38.     000400,    /* short constant */
  39.     000400,    /* string */
  40.     000400,    /* float */
  41.     000400,    /* double */
  42.     000400,    /* long constant */
  43.     000400,    /* long constant <= 16 bits */
  44.     000000,    /* 27 */
  45.     000000,    /* 28 */
  46.     000000, /* 29 */
  47.     034203,    /* ++pre */
  48.     034203,    /* --pre */
  49.     034203,    /* ++post */
  50.     034203,    /* --post */
  51.     034200,    /* !un */
  52.     034202,    /* &un */
  53.     034220,    /* *un */
  54.     034200,    /* -un */
  55.     034220,    /* ~un */
  56.     036001,    /* . (structure reference) */
  57.     030101,    /* + */
  58.     030001,    /* - */
  59.     032101,    /* * */
  60.     032001,    /* / */
  61.     032001,    /* % */
  62.     026061,    /* >> */
  63.     026061,    /* << */
  64.     020161,    /* & */
  65.     017161,    /* | */
  66.     017161,    /* ^ */
  67.     036001,    /* -> */
  68.     000000, /* int -> double */
  69.     000000, /* double -> int */
  70.     016001, /* && */
  71.     015001, /* || */
  72.     030001, /* &~ */
  73.     000000, /* 56 */
  74.     000000, /* 57 */
  75.     000000, /* 58 */
  76.     000000,    /* 59 */
  77.     022005,    /* == */
  78.     022005,    /* != */
  79.     024005,    /* <= */
  80.     024005,    /* < */
  81.     024005,    /* >= */
  82.     024005,    /* > */
  83.     024005,    /* <p */
  84.     024005,    /* <=p */
  85.     024005,    /* >p */
  86.     024005,    /* >=p */
  87.     012213,    /* =+ */
  88.     012213,    /* =- */
  89.     012213,    /* =* */
  90.     012213,    /* =/ */
  91.     012213,    /* =% */
  92.     012253,    /* =>> */
  93.     012253,    /* =<< */
  94.     012253,    /* =& */
  95.     012253,    /* =| */
  96.     012253,    /* =^ */
  97.     012213,    /* = */
  98.     000000,    /* 81 */
  99.     000000,    /* 82 */
  100.     000000,    /* 83 */
  101.     000000,    /* 84 */
  102.     000000,    /* 85 */
  103.     000000,    /* 86 */
  104.     000000,    /* 87 */
  105.     000000,    /* 88 */
  106.     000000,    /* 89 */
  107.     014201,    /* ? */
  108.     034200,    /* sizeof */
  109.     000000,    /* 92 */
  110.     021101,    /* min */
  111.     021101,    /* minp */
  112.     021101,    /* max */
  113.     021101,    /* maxp */
  114.     007001,    /* , */
  115.     000000,    /* 98 */
  116.     000000,    /* 99 */
  117.     036001,    /* call */
  118.     036001,    /* mcall */
  119.     000000,    /* goto */
  120.     000000,    /* jump cond */
  121.     000000,    /* branch cond */
  122.     000000,    /* 105 */
  123.     000000, /* 106 */
  124.     000000,    /* 107 */
  125.     000000,    /* 108 */
  126.     000000,    /* char->int */
  127.     000000    /* force r0 */
  128. };
  129.  
  130. /*
  131.  * conversion table:
  132.  * FTI: float (or double) to integer
  133.  * ITF: integer to float
  134.  * ITP: integer to pointer
  135.  * ITL: integer to long
  136.  * LTI: long to integer
  137.  * LTF: long to float
  138.  * FTL: float to long
  139.  * PTI: pointer to integer
  140.  * LTP: long to ptr (ptr[long])
  141.  * XX: usually illegal
  142.  * When FTI, LTI, FTL are added in they specify
  143.  * that it is the left operand that should be converted.
  144.  * For + this is done and the conversion is turned back into
  145.  * ITF, ITL, LTF.
  146.  * For = however the left operand can't be converted
  147.  * and the specified conversion is applied to the rhs.
  148.  */
  149. char cvtab[4][4] {
  150. /*        int    double        long        ptr */
  151. /* int */    0,    (FTI<<4)+ITF,    (LTI<<4)+ITL,    (ITP<<4)+ITP,    
  152. /* double */    ITF,    0,        LTF,        XX,
  153. /* long */    ITL,    (FTL<<4)+LTF,    0,        (LTP<<4)+LTP,
  154. /* ptr */    ITP,    XX,        LTP,        PTI,
  155. };
  156.  
  157. /*
  158.  * relate conversion numbers to operators
  159.  */
  160. char    cvntab[] {
  161.     0, ITOF, ITOL, LTOF, ITOP, PTOI, FTOI, LTOI, FTOL, LTOP,
  162. };
  163.  
  164. /*
  165.  * character type table
  166.  */
  167. char ctab[] {
  168.     EOFC,    INSERT,    UNKN,    UNKN,    UNKN,    UNKN,    UNKN,    UNKN,
  169.     UNKN,    SPACE,    NEWLN,    SPACE,    SPACE,    UNKN,    UNKN,    UNKN,
  170.     UNKN,    UNKN,    UNKN,    UNKN,    UNKN,    UNKN,    UNKN,    UNKN,
  171.     UNKN,    UNKN,    UNKN,    UNKN,    UNKN,    UNKN,    UNKN,    UNKN,
  172.     SPACE,    EXCLA,    DQUOTE,    SHARP,    UNKN,    MOD,    AND,    SQUOTE,
  173.     LPARN,    RPARN,    TIMES,    PLUS,    COMMA,    MINUS,    PERIOD,    DIVIDE,
  174.     DIGIT,    DIGIT,    DIGIT,    DIGIT,    DIGIT,    DIGIT,    DIGIT,    DIGIT,
  175.     DIGIT,    DIGIT,    COLON,    SEMI,    LESS,    ASSIGN,    GREAT,    QUEST,
  176.     UNKN,    LETTER,    LETTER,    LETTER,    LETTER,    LETTER,    LETTER,    LETTER,
  177.     LETTER,    LETTER,    LETTER,    LETTER,    LETTER,    LETTER,    LETTER,    LETTER,
  178.     LETTER,    LETTER,    LETTER,    LETTER,    LETTER,    LETTER,    LETTER,    LETTER,
  179.     LETTER,    LETTER,    LETTER,    LBRACK,    BSLASH,    RBRACK,    EXOR,    LETTER,
  180.     UNKN,    LETTER,    LETTER,    LETTER,    LETTER,    LETTER,    LETTER,    LETTER,
  181.     LETTER,    LETTER,    LETTER,    LETTER,    LETTER,    LETTER,    LETTER,    LETTER,
  182.     LETTER,    LETTER,    LETTER,    LETTER,    LETTER,    LETTER,    LETTER,    LETTER,
  183.     LETTER,    LETTER,    LETTER,    LBRACE,    OR,    RBRACE,    COMPL,    UNKN
  184. };
  185.