home *** CD-ROM | disk | FTP | other *** search
- /* atbls2 -- Administrative module, Tables
-
- Copyright (c) 1983 by James F. Gimpel
- Copyright (c) 1983, 1984 by JMI Software Consultants, Inc.
-
- atbls1.c and atbls2.c contain tables of keywords and operators
- that will enable a user to add custom functions
- and statements and modify the meaning of operators.
- */
- #include "at.h"
-
-
- /* Operator Table
- */
-
- #define LR 1 /* associates left to right */
- #define COE dtf_COERC /* Coerce to this type */
-
- struct opstruct optbl[] =
- {
- op_PLUS, 1, 80, 0, "$R ", dt_DBL, dt_DBL,
- /* the next three lines must appear in this order, so that the
- string concatenation optimization will work
- */
- op_PLUS, 2, 60, LR, "s_cat(&$TS, $L, $R)", dt_STR, dt_STR,
- op_PLUS, 2, 59, LR, "s_cat(&$TS, $L, $R)", dt_STR, dt_STR,
- op_PLUS, 2, 60, LR, "$L + $R", dt_DBL, dt_DBL,
-
- op_MINUS, 1, 80, 0, "-$R ", dt_DBL, dt_DBL,
- op_MINUS, 2, 60, LR, "$L - $R", dt_DBL, dt_DBL,
-
- op_MUL, 2, 70, LR, "$L * $R", dt_DBL, dt_DBL,
-
- op_DIV, 2, 70, LR, "(double)$L / $R", dt_INT, dt_DBL,
- op_DIV, 2, 70, LR, "$L / $R", dt_DBL, dt_DBL,
- op_MOD, 2, 70, LR, "($L % $R)", dt_INT|COE, dt_INT,
- op_IDIV, 2, 70, LR, "$L / $R", dt_INT|COE, dt_INT,
-
- op_EXPON, 2, 90, LR, "f_raise($L, $R)", dt_DBL|COE, dt_DBL,
-
- op_GE, 2, 50, LR, "$L >= $R", dt_DBL, dt_RBOOL,
- op_GE, 2, 50, LR, "s_comp($L, $R) >= 0", dt_STR, dt_RBOOL,
-
- op_GT, 2, 50, LR, "$L > $R", dt_DBL, dt_RBOOL,
- op_GT, 2, 50, LR, "s_comp($L, $R) > 0", dt_STR, dt_RBOOL,
-
- op_EQ, 2, 50, LR, "$L == $R", dt_DBL, dt_RBOOL,
- op_EQ, 2, 50, LR, "s_comp($L, $R) == 0", dt_STR, dt_RBOOL,
-
- op_NE, 2, 50, LR, "$L != $R", dt_DBL, dt_RBOOL,
- op_NE, 2, 50, LR, "s_comp($L, $R) != 0", dt_STR, dt_RBOOL,
-
- op_LT, 2, 50, LR, "$L < $R", dt_DBL, dt_RBOOL,
- op_LT, 2, 50, LR, "s_comp($L, $R) < 0", dt_STR, dt_RBOOL,
-
- op_LE, 2, 50, LR, "$L <= $R", dt_DBL, dt_RBOOL,
- op_LE, 2, 50, LR, "s_comp($L, $R) <= 0", dt_STR, dt_RBOOL,
-
- op_NOT , 1, 40, 0, "~($R)", dt_BOOL|COE, dt_BOOL,
- op_OR, 2, 20, LR, "$L | $R", dt_BOOL|COE, dt_BOOL,
- op_AND, 2, 30, LR, "$L & $R", dt_BOOL|COE, dt_BOOL,
-
- op_EQV, 2, 10, LR, "~(($L) ^ ($R))", dt_BOOL|COE, dt_BOOL,
- op_XOR, 2, 10, LR, "($L) ^ ($R)", dt_BOOL|COE, dt_BOOL,
- op_IMP, 2, 10, LR, "~($L) | ($R)", dt_BOOL|COE, dt_BOOL,
-
- op_ADDR, 1,100, 0, "&$R", 0, dt_ADDR,
- op_FENCE, 0, 0, 0, NULLSTR, 0, 0,
- };
-
- GLOBAL int num_op = sizeof(optbl) / sizeof(struct opstruct);
-
- /* This table places a character into a category for the purpose
- of lexical scanning of tokens. Other uses of characters such as
- statement separation, line-continuation, etc. are defined elsewhere.
- */
-
- GLOBAL TEXT char_type[NUM_CHARS] =
- {
- ct_ILL,ct_ILL,ct_ILL,ct_ILL,ct_ILL,ct_ILL,ct_ILL,ct_ILL, /* 0 - 7 */
- ct_ILL,ct_ILL,ct_ILL,ct_ILL,ct_ILL,ct_ILL,ct_ILL,ct_ILL, /* 8 - 15 */
- ct_ILL,ct_ILL,ct_ILL,ct_ILL,ct_ILL,ct_ILL,ct_ILL,ct_ILL, /* 16 - 23 */
- ct_ILL,ct_ILL,ct_ILL,ct_ILL,ct_ILL,ct_ILL,ct_ILL,ct_ILL, /* 24 - 31 */
- ct_ILL, /* blank */
- ctf_ID|ct_ILL, /* ! */
- ct_QT, /* " */
- ctf_ID|ctf_SIMP|0, /* # */
- ctf_ID|ct_DOL, /* $ */
- ctf_ID|ct_ILL, /* % */
- ct_AMPER, /* & */
- ctf_SIMP|11, /* ' */
- ctf_SIMP|1, /* ( */
- ctf_SIMP|2, /* ) */
- ct_STAR, /* * */
- ctf_SIMP|3, /* + */
- ctf_SIMP|4, /* , */
- ct_MINUS, /* - */
- ct_PER|ctf_ID, /* . */
- ctf_SIMP|5, /* / */
- CT_DIGIT, CT_DIGIT, CT_DIGIT, CT_DIGIT, CT_DIGIT, /* 0 - 4 */
- CT_DIGIT, CT_DIGIT, CT_DIGIT, CT_DIGIT, CT_DIGIT, /* 5 - 9 */
- ctf_SIMP|6, /* : */
- ctf_SIMP|7, /* ; */
- ct_REL, /* < */
- ct_REL, /* = */
- ct_REL, /* > */
- ct_ILL, /* ? */
- ctf_SIMP|8, /* @ */
- CT_LET, CT_LET, CT_LET, CT_LET, CT_LET, /* A - E */
- CT_LET, CT_LET, CT_LET, CT_LET, CT_LET, /* F - J */
- CT_LET, CT_LET, CT_LET, CT_LET, CT_LET, /* K - O */
- CT_LET, CT_LET, CT_LET, CT_LET, CT_LET, /* P - T */
- CT_LET, CT_LET, CT_LET, CT_LET, CT_LET, CT_LET, /* U - Z */
- ct_ILL, /* [ */
- ctf_SIMP|10, /* \ */
- ct_ILL, /* ] */
- ctf_SIMP|9, /* ^ */
- ct_ILL|ctf_CID, /* _ */
- ct_ILL, /* ` */
- CT_LET, CT_LET, CT_LET, CT_LET, CT_LET, /* a - e */
- CT_LET, CT_LET, CT_LET, CT_LET, CT_LET, /* f - j */
- CT_LET, CT_LET, CT_LET, CT_LET, CT_LET, /* k - o */
- CT_LET, CT_LET, CT_LET, CT_LET, CT_LET, /* p - t */
- CT_LET, CT_LET, CT_LET, CT_LET, CT_LET, CT_LET, /* u - z */
- ct_ILL, ct_ILL, ct_ILL, ct_ILL, ct_ILL, /* { | } ~ del */
- };
-
- /* This table is an auxiliary to char_type. For those characters
- that lexically constitute an entire token (all the time)
- and which accordingly are flagged with ctf_SIMP in the char_type[]
- table, have their respective token indicated here.
- The index to this table is found embedded in the char_type[] table.
- */
-
- GLOBAL TOKEN tok_type[] =
- {
- t_SHARP, /* # */
- t_LP, /* ( */
- t_RP, /* ) */
- op_PLUS, /* + */
- t_COMMA, /* , */
- op_DIV, /* / */
- t_EOS, /* : */
- t_SEMI, /* ; */
- op_ADDR, /* @ */
- op_EXPON, /* ^ */
- op_IDIV, /* \ */
- t_REM, /* ' */
- };