home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l200 / 6.ddi / TRAN / ATBLS2.C < prev    next >
Encoding:
C/C++ Source or Header  |  1986-08-21  |  5.6 KB  |  150 lines

  1. /*      atbls2 -- Administrative module, Tables
  2.         
  3.         Copyright (c) 1983  by  James F. Gimpel
  4.         Copyright (c) 1983, 1984 by JMI Software Consultants, Inc.
  5.  
  6.         atbls1.c and atbls2.c contain tables of keywords and operators
  7.         that will enable a user to add custom functions
  8.         and statements and modify the meaning of operators.
  9. */
  10. #include "at.h"
  11.  
  12.  
  13. /*  Operator Table
  14. */
  15.  
  16. #define LR 1        /* associates left to right */
  17. #define COE dtf_COERC   /* Coerce to this type */
  18.  
  19. struct opstruct optbl[] =
  20.     {
  21. op_PLUS,  1, 80,  0, "$R ",                 dt_DBL,  dt_DBL,
  22. /* the next three lines must appear in this order, so that the
  23. string concatenation optimization will work
  24. */
  25. op_PLUS,  2, 60, LR, "s_cat(&$TS, $L, $R)", dt_STR,  dt_STR,
  26. op_PLUS,  2, 59, LR, "s_cat(&$TS, $L, $R)", dt_STR,  dt_STR,
  27. op_PLUS,  2, 60, LR, "$L + $R",             dt_DBL,  dt_DBL,
  28.  
  29. op_MINUS, 1, 80,  0, "-$R ",                dt_DBL,  dt_DBL,
  30. op_MINUS, 2, 60, LR, "$L - $R",             dt_DBL,  dt_DBL,
  31.  
  32. op_MUL,   2, 70, LR, "$L * $R",             dt_DBL,  dt_DBL,
  33.  
  34. op_DIV,   2, 70, LR, "(double)$L / $R",     dt_INT,  dt_DBL,
  35. op_DIV,   2, 70, LR, "$L / $R",             dt_DBL,  dt_DBL,
  36. op_MOD,   2, 70, LR, "($L % $R)",           dt_INT|COE,  dt_INT,
  37. op_IDIV,  2, 70, LR, "$L / $R",             dt_INT|COE,  dt_INT,
  38.  
  39. op_EXPON, 2, 90, LR, "f_raise($L, $R)",     dt_DBL|COE,  dt_DBL,
  40.  
  41. op_GE,    2, 50, LR, "$L >= $R",            dt_DBL,  dt_RBOOL,
  42. op_GE,    2, 50, LR, "s_comp($L, $R) >= 0", dt_STR,  dt_RBOOL,
  43.  
  44. op_GT,    2, 50, LR, "$L > $R",             dt_DBL,  dt_RBOOL,
  45. op_GT,    2, 50, LR, "s_comp($L, $R) > 0",  dt_STR,  dt_RBOOL,
  46.  
  47. op_EQ,    2, 50, LR, "$L == $R",            dt_DBL,  dt_RBOOL,
  48. op_EQ,    2, 50, LR, "s_comp($L, $R) == 0", dt_STR,  dt_RBOOL,
  49.  
  50. op_NE,    2, 50, LR, "$L != $R",            dt_DBL,  dt_RBOOL,
  51. op_NE,    2, 50, LR, "s_comp($L, $R) != 0", dt_STR,  dt_RBOOL,
  52.  
  53. op_LT,    2, 50, LR, "$L < $R",             dt_DBL,  dt_RBOOL,
  54. op_LT,    2, 50, LR, "s_comp($L, $R) < 0",  dt_STR,  dt_RBOOL,
  55.  
  56. op_LE,    2, 50, LR, "$L <= $R",            dt_DBL,  dt_RBOOL,
  57. op_LE,    2, 50, LR, "s_comp($L, $R) <= 0", dt_STR,  dt_RBOOL,
  58.  
  59. op_NOT  , 1, 40,  0, "~($R)",               dt_BOOL|COE,  dt_BOOL,
  60. op_OR,    2, 20, LR, "$L | $R",             dt_BOOL|COE,  dt_BOOL,
  61. op_AND,   2, 30, LR, "$L & $R",             dt_BOOL|COE,  dt_BOOL,
  62.  
  63. op_EQV,   2, 10, LR, "~(($L) ^ ($R))",      dt_BOOL|COE,  dt_BOOL,
  64. op_XOR,   2, 10, LR, "($L) ^ ($R)",         dt_BOOL|COE,  dt_BOOL,
  65. op_IMP,   2, 10, LR, "~($L) | ($R)",        dt_BOOL|COE,  dt_BOOL,
  66.  
  67. op_ADDR,  1,100,  0, "&$R",                 0,        dt_ADDR,
  68. op_FENCE, 0,  0,  0, NULLSTR,               0,          0,
  69. };
  70.  
  71. GLOBAL int num_op = sizeof(optbl) / sizeof(struct opstruct);
  72.  
  73. /*  This table places a character into a category for the purpose
  74.     of lexical scanning of tokens.  Other uses of characters such as
  75.     statement separation, line-continuation, etc. are defined elsewhere.
  76. */
  77.  
  78. GLOBAL TEXT char_type[NUM_CHARS] = 
  79.     {
  80.     ct_ILL,ct_ILL,ct_ILL,ct_ILL,ct_ILL,ct_ILL,ct_ILL,ct_ILL,   /* 0 - 7 */
  81.     ct_ILL,ct_ILL,ct_ILL,ct_ILL,ct_ILL,ct_ILL,ct_ILL,ct_ILL,   /* 8 - 15 */
  82.     ct_ILL,ct_ILL,ct_ILL,ct_ILL,ct_ILL,ct_ILL,ct_ILL,ct_ILL,   /* 16 - 23 */
  83.     ct_ILL,ct_ILL,ct_ILL,ct_ILL,ct_ILL,ct_ILL,ct_ILL,ct_ILL,   /* 24 - 31 */
  84.     ct_ILL,         /* blank */
  85.     ctf_ID|ct_ILL,          /*  !    */
  86.     ct_QT,          /*  "    */
  87.     ctf_ID|ctf_SIMP|0,      /*  #    */
  88.     ctf_ID|ct_DOL,          /*  $    */
  89.     ctf_ID|ct_ILL,          /*  %    */
  90.     ct_AMPER,       /*  &    */
  91.     ctf_SIMP|11,    /*  '    */
  92.     ctf_SIMP|1,     /*  (    */
  93.     ctf_SIMP|2,     /*  )    */
  94.     ct_STAR,        /*  *    */
  95.     ctf_SIMP|3,     /*  +    */
  96.     ctf_SIMP|4,     /*  ,    */
  97.     ct_MINUS,       /*  -    */
  98.     ct_PER|ctf_ID,  /*  .    */
  99.     ctf_SIMP|5,     /*  /    */
  100.     CT_DIGIT, CT_DIGIT, CT_DIGIT, CT_DIGIT, CT_DIGIT,       /*  0 - 4  */
  101.     CT_DIGIT, CT_DIGIT, CT_DIGIT, CT_DIGIT, CT_DIGIT,       /*  5 - 9  */
  102.     ctf_SIMP|6,     /*  :    */
  103.     ctf_SIMP|7,     /*  ;    */
  104.     ct_REL,         /*  <    */
  105.     ct_REL,         /*  =    */
  106.     ct_REL,         /*  >    */
  107.     ct_ILL,         /*  ?    */
  108.     ctf_SIMP|8,     /*  @    */
  109.     CT_LET, CT_LET, CT_LET, CT_LET, CT_LET,         /*  A - E  */
  110.     CT_LET, CT_LET, CT_LET, CT_LET, CT_LET,         /*  F - J  */
  111.     CT_LET, CT_LET, CT_LET, CT_LET, CT_LET,         /*  K - O  */
  112.     CT_LET, CT_LET, CT_LET, CT_LET, CT_LET,         /*  P - T  */
  113.     CT_LET, CT_LET, CT_LET, CT_LET, CT_LET, CT_LET, /*  U - Z  */
  114.     ct_ILL,         /*  [    */
  115.     ctf_SIMP|10,    /*  \    */
  116.     ct_ILL,         /*  ]    */
  117.     ctf_SIMP|9,     /*  ^    */
  118.     ct_ILL|ctf_CID, /*  _    */
  119.     ct_ILL,         /*  `    */
  120.     CT_LET, CT_LET, CT_LET, CT_LET, CT_LET,         /*  a - e  */
  121.     CT_LET, CT_LET, CT_LET, CT_LET, CT_LET,         /*  f - j  */
  122.     CT_LET, CT_LET, CT_LET, CT_LET, CT_LET,         /*  k - o  */
  123.     CT_LET, CT_LET, CT_LET, CT_LET, CT_LET,         /*  p - t  */
  124.     CT_LET, CT_LET, CT_LET, CT_LET, CT_LET, CT_LET, /*  u - z  */
  125.     ct_ILL, ct_ILL, ct_ILL, ct_ILL, ct_ILL,  /* { | } ~ del */
  126.     };
  127.  
  128. /*  This table is an auxiliary to char_type.  For those characters
  129.     that lexically constitute an entire token (all the time)
  130.     and which accordingly are flagged with ctf_SIMP in the char_type[]
  131.     table, have their respective token indicated here.
  132.     The index to this table is found embedded in the char_type[] table.
  133. */
  134.  
  135. GLOBAL TOKEN tok_type[]  =
  136.     {
  137.     t_SHARP,    /*  #  */
  138.     t_LP,       /*  (  */
  139.     t_RP,       /*  )  */
  140.     op_PLUS,    /*  +  */
  141.     t_COMMA,    /*  ,  */
  142.     op_DIV,     /*  /  */
  143.     t_EOS,      /*  :  */
  144.     t_SEMI,     /*  ;  */
  145.     op_ADDR,    /*  @  */
  146.     op_EXPON,   /*  ^  */
  147.     op_IDIV,    /*  \  */
  148.     t_REM,      /*  '  */
  149.     };
  150.