home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Amiga 13 / MA_Cover_13.bin / source / c / apl / tab.c < prev   
Encoding:
C/C++ Source or Header  |  1999-11-23  |  6.4 KB  |  350 lines

  1. /*
  2.  * This table defines the operators in APL\11.
  3.  * The first entry is the character representing
  4.  * the operator, the second is the unique operator
  5.  * identifier (which should give you a hint as
  6.  * to what the operator is), and the third is
  7.  * the operator type, of interest only to the
  8.  * interpreter.
  9.  * Those characters represented by octal numbers are actually
  10.  * two-character overstrikes.  Ignore the leading "2", and
  11.  * the rest of the number is an index into "chartab", below,
  12.  * which lists the two-character overstrikes.  Overstrikes
  13.  * may be in either order.
  14.  *
  15.  * Note: What isn't shown here is that unary minus
  16.  * is ` (backwards apostrophe).  This is handled in lex.c, a0.c
  17.  * and a2.c (both input and output).
  18.  */
  19. struct tab
  20. {
  21.     int    input;
  22.     int    lexval;
  23.     int    retval;
  24. }
  25. tab[] = {
  26.  
  27. /*
  28.  * one of a kind
  29.  */
  30.  
  31.     '(',    unk,lpar,
  32.     ')',    unk,rpar,
  33.     '[',    unk,lbkt,
  34.     ']',    unk,rbkt,
  35.     '/',    COM,com,
  36.     0200  , COM0,com0,
  37.     '\\',    EXD,com,
  38.     0201  , EXD0,com0,
  39.     '\'',    unk,strng,
  40.     'J',    unk,null,
  41.     '.',    IPROD,dot,
  42.     'L',    QUAD,quad,
  43.     0202  , QQUAD,quad,
  44.     0203  , CQUAD,quad,
  45.     ';',    unk,semi,
  46.     ':',    unk,cln,
  47.     0204  , COMNT,comnt,
  48.     'C',    COMNT,comnt,
  49.     '}',    BRAN0,tran,
  50.  
  51. /*
  52.  * dyadic scalars
  53.  *    op2 op1 v (dyadic op)
  54.  */
  55.  
  56.     '<',    LT,dscal,
  57.     '>',    GT,dscal,
  58.     '$',    LE,dscal,
  59.     0220,    LE,dscal,
  60.     '&',    GE,dscal,
  61.     0221,    GE,dscal,
  62.     '=',    EQ,dscal,
  63.     '#',    NE,dscal,
  64.     0222,    NE,dscal,
  65.     '^',    AND,dscal,
  66.     'A',    AND,dscal,
  67.     'Q',    OR,dscal,
  68.     'V',    OR,dscal,
  69.     0205  , NAND,dscal,
  70.     0231,    NAND,dscal,
  71.     0206  , NOR,dscal,
  72.     0223,    NAND,dscal,
  73.     0224,    NOR,dscal,
  74.  
  75. /*
  76.  * monadic or dyadic scalars
  77.  *    op2 op1 v (dyadic op)
  78.  *    op1 v+1 (monadic op)
  79.  */
  80.  
  81.     '+',    ADD,mdscal,
  82.     '-',    SUB,mdscal,
  83.     'M',    MUL,mdscal,
  84.     'X',    MUL,mdscal,
  85.     0225,    MUL,mdscal,
  86.     'P',    DIV,mdscal,
  87.     0240,    DIV,mdscal,
  88.     '%',    DIV,mdscal,
  89.     0226,    DIV,mdscal,
  90.     '|',    MOD,mdscal,
  91.     'D',    MIN,mdscal,
  92.     'S',    MAX,mdscal,
  93.     '*',    PWR,mdscal,
  94.     0207  , LOG,mdscal,
  95.     'O',    CIR,mdscal,
  96.     0210  , COMB,mdscal,
  97.     '!',    COMB,mdscal,
  98.  
  99. /*
  100.  * monadic
  101.  *    op1 v (monadic op)
  102.  */
  103.  
  104.     '~',    NOT,m,
  105.     0241,    EPS+1,m,
  106. /*
  107.  * dyadic
  108.  *    op2 op1 v (dyadic op)
  109.  */
  110.  
  111.     'N',    REP,d,
  112.     'Y',    TAKE,d,
  113.     'U',    DROP,d,
  114.     '_',    ASGN,asg,
  115.     '{',    ASGN,asg,
  116.  
  117. /*
  118.  * monadic or dyadic
  119.  *    op2 op1 v (dyadic op)
  120.  *    op1 v+1 (monadic op)
  121.  */
  122.  
  123.     'E',    EPS,md,
  124.     'B',    BASE,md,
  125.     '?',    DEAL,md,
  126.     'R',    DRHO,md,
  127.     'I',    DIOT,md,
  128.     0211  , ROT0,md,
  129.     0212  , DTRN,md,
  130.     0213  , DIBM,md,
  131.     0214  , DDOM,md,
  132.     0242,    DFMT,md,
  133.  
  134.  
  135.  
  136. /*
  137.  * monadic with optional subscript
  138.  *    op1 v (monadic op)
  139.  *    op1 sub v+1 (subscripted monadic op)
  140.  */
  141.  
  142.     0215  , GDU,msub,
  143.     0216  , GDD,msub,
  144.     0227,    GDU,msub,
  145.     0230,    GDD,msub,
  146.  
  147. /*
  148.  * dyadic with optional subscript
  149.  *    op2 op1 v (dyadic op)
  150.  *    op2 op1 sub v+1 (subscripted dyadic op)
  151.  */
  152.  
  153.  
  154. /*
  155.  * monadic or dyadic with optional subscript
  156.  *    op2 op1 v (dyadic op)
  157.  *    op1 v+1 (monadic op)
  158.  *    op2 op1 sub v+2 (subscripted dyadic op)
  159.  *    op1 sub v+3 (subscripted monadic op)
  160.  */
  161.  
  162.     0217  , ROT,mdsub,
  163.     ',',    CAT,mdsub,
  164.  
  165. /*
  166.  *    ISP and PSI
  167.  */
  168.     0232,    PSI,d,
  169.     0233,    ISP,d,
  170.  
  171. /*
  172.  *    other, non-function
  173.  */
  174.     0234,    unk,null,
  175.     0235,    unk,null,
  176.     0236,    unk,null,
  177.     0237,    unk,null,
  178.     '@',    unk,null,
  179.  
  180. /*
  181.  * end of list
  182.  */
  183.  
  184.     0
  185. };
  186.  
  187. struct {
  188.     char    *ct_name;        /* command name string */
  189.     int    ct_ytype;        /* command type */
  190.     int    ct_ylval;        /* "yylval" value */
  191. } comtab[] = {
  192.     "clear",    comnull,    CLEAR,
  193.     "continue",    comnull,    CONTIN,
  194.     "copy",        comnam,        COPY,
  195.     "debug",    comnull,    DEBUG,
  196.     "digits",    comexpr,    DIGITS,
  197.     "drop",        comlist,    DROPC,
  198.     "edit",        comnam,        EDIT,
  199.     "editf",    comnam,        EDITF,
  200.     "write",    comnam,        WRITE,
  201.     "trace",    comnull,    TRACE,
  202.     "untrace",    comnull,    UNTRACE,
  203.     "erase",    comlist,    ERASE,
  204.     "fns",        comnull,    FNS,
  205.     "fuzz",        comexpr,    FUZZ,
  206.     "lib",        comnull,    LIB,
  207.     "load",        comnam,        LOAD,
  208.     "off",        comnull,    OFF,
  209.     "origin",    comexpr,    ORIGIN,
  210.     "read",        comnam,        READ,
  211.     "save",        comnam,        SAVE,
  212.     "vars",        comnull,    VARS,
  213.     "width",    comexpr,    WIDTH,
  214.     "vsave",    comnam,        VSAVE,
  215.     "script",    comnam,        SCRIPT,
  216.     "reset",    comnull,    RESET,
  217.     "si",        comnull,    SICOM,
  218.     "code",        comnam,        CODE,
  219.     "del",        comnam,        DEL,
  220.     "shell",    comnull,    SHELL,
  221.     "list",        comnam,        LIST,
  222.     "prws",        comnull,    PRWS,
  223.     "memory",    comnull,    MEMORY,
  224.     "pload",    comnam,        PLOAD,
  225.     "psave",    comnam,        PSAVE,
  226.     0,        unk
  227. };
  228.  
  229. /*
  230.  * List of two-character escapes.  Indexed by 02XX entries
  231.  * in "tab", above.  Entries must be in lexical order, i.e.
  232.  * 'V~' will work, '~V' will not (since overstrikes are
  233.  * sorted before they are looked up).  'V~' is 6 down in
  234.  * the table, and thus corresponds to 0206,
  235.  * which "tab" shows to be NOR.
  236.  */
  237. int     chartab[] = {
  238.  
  239.     '-/',        /* 0200 comprs */
  240.     '-\\',        /* 0201 expand */
  241.     '\'L',        /* 0202 quote quad */
  242.     'LO',        /* 0203 circle quad */
  243.     'CJ',        /* 0204 lamp */
  244.     '^~',        /* 0205 nand */
  245.     'V~',        /* 0206 nor */
  246.     '*O',        /* 0207 log */
  247.     '\'.',        /* 0210 comb/fact ('!') */
  248.     '-O',        /* 0211 rotate */
  249.     'O\\',        /* 0212 transpose */
  250.     'BN',        /* 0213 i beam */
  251.     '%L',        /* 0214 domino */
  252.     'A|',        /* 0215 grade up */
  253.     'V|',        /* 0216 grade dn */
  254.     'O|',        /* 0217 rotate */
  255.     '<=',        /* 0220 less eq */
  256.     '=>',        /* 0221 greater eq */
  257.     '/=',        /* 0222 not eq */
  258.     'A~',        /* 0223 nand */
  259.     'Q~',        /* 0224 nor */
  260.     '/\\',        /* 0225 multiply */
  261.     '-:',        /* 0226 divide */
  262.     'H|',        /* 0227 another grade up */
  263.     'G|',        /* 0230 another dgrade dn */
  264.     '&~',        /* 0231 yet another nand */
  265.     'U|',        /* 0232 PSI */
  266.     'C|',        /* 0233 ISP */
  267.     'Y~',        /* 0234 bracket 1 */
  268.     'U~',        /* 0235 bracket 2 */
  269.     '-U',        /* 0236 another bracket 2 */
  270.     '-Y',        /* 0237 another bracket 2 */
  271.     '//',        /* 0240 alternate divide */
  272.     'BJ',        /* 0241 standard execute */
  273.     'JN',        /* 0242 format */
  274. /*
  275.  *    function alpha() in lex.c must be changed whenever this
  276.  *    table is updated.  It must know the index of the alternate
  277.  *    character set (currently 0243)
  278.  */
  279.     'Fa',        /* alternate character set */
  280.     'Fb',
  281.     'Fc',
  282.     'Fd',
  283.     'Fe',
  284.     'Ff',
  285.     'Fg',
  286.     'Fh',
  287.     'Fi',
  288.     'Fj',
  289.     'Fk',
  290.     'Fl',
  291.     'Fm',
  292.     'Fn',
  293.     'Fo',
  294.     'Fp',
  295.     'Fq',
  296.     'Fr',
  297.     'Fs',
  298.     'Ft',
  299.     'Fu',
  300.     'Fv',
  301.     'Fw',
  302.     'Fx',
  303.     'Fy',
  304.     'Fz',
  305.     0
  306. };
  307.  
  308. /*
  309.  *    qtab -- table of valid quad functions
  310.  *    the format of the qtab is the similar to tab, above
  311.  *
  312.  */
  313. struct qtab{
  314.     char    *qname;
  315.     int    qtype;
  316.     int    rtype;
  317. }
  318. qtab[] = {
  319.  
  320.     "lx",    XQUAD,    quad,
  321.     "width", QWID,    quad,
  322.     "run",    QRUN,    m,
  323.     "fuzz",    QFUZZ,    quad,
  324.     "fork",    QFORK,    m,
  325.     "wait",    QWAIT,    m,
  326.     "exec",    QEXEC,    m,
  327.     "cr",    QCRP,    m,
  328.     "fx",    FDEF,    m,
  329.     "exit",    QEXIT,    m,
  330.     "pipe",    QPIPE,    m,
  331.     "chdir",QCHDIR,    m,
  332.     "open",    QOPEN,    d,
  333.     "close", QCLOSE, m,
  334.     "read",    QREAD,    d,
  335.     "write",QWRITE,    d,
  336.     "creat",QCREAT,    d,
  337.     "seek",    QSEEK,    m,
  338.     "kill",    QKILL,    d,
  339.     "rd",    QRD,    m,
  340.     "rm",    QUNLNK,    m,
  341.     "dup",    QDUP,    m,
  342.     "ap",    QAP,    d,
  343.     "rline",QRD,    m,
  344.     "nc",    QNC,    m,
  345.     "sig",    QSIGNL,    d,
  346.     "float",QFLOAT,    m,
  347.     "nl"    ,QNL,    m,
  348.     0
  349. };
  350.