home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rximc175.zip / const.h < prev    next >
Text File  |  2002-08-06  |  17KB  |  419 lines

  1. /* The constants and data types of REXX/imc      (C) Ian Collier 1992 */
  2.  
  3. #ifndef _const_h
  4. #define _const_h
  5.  
  6. #define VER "beta-1.75"
  7. #define LEVEL "4.00"  /* Language level supported */
  8.  
  9. /* A paranoid Solaris detector. */
  10. #if (defined(__svr4__)||defined(__SVR4)||defined(__SVR4)) && (defined(sun)||defined(__sun)||defined(__sun__))
  11. #define Solaris
  12. #endif
  13.  
  14. #define four       (sizeof(int))
  15. #ifdef POINTER64
  16. #define align(x)   (((x)+7)&~7)
  17. #define toalign(x) (((~(x))+1)&7)
  18. #else
  19. #define align(x)   (((x)+3)&~3)
  20. #define toalign(x) (((~(x))+1)&3)
  21. #endif
  22.  
  23. #define rxmathname "rxmathfn"   /* The basenames of the two REXX auxiliary */
  24. #define rxquename  "rxque"      /* files  */
  25.  
  26. #ifndef filetype
  27. #define filetype   ".rexx"      /* Default file extension */
  28. #endif
  29.  
  30. #define maxopstack 30    /* Maximum number of pending operations in an expr */
  31. #define maxvarname 250   /* Maximum length of a variable name or label */
  32. #define maxargs 30       /* Maximum number of arguments in function call */
  33. #define maxextension 32  /* Maximum length of a file extension */
  34. #define maxenviron 31    /* Maximum length of an environment name */
  35. #define maxexp 999999999 /* maximum exponent of a number (must fit into int) */
  36. #define maxdigits 10000  /* maximum allowable setting for NUMERIC DIGITS */
  37. #define maxtracelen 500  /* maximum length of a line of trace */
  38. #define traceindent 1    /* Spaces per indentation level in traceback */
  39. #define STDIN 0          /* = fileno(stdin) */
  40.  
  41. #define cnull (char *)0  /* Various null pointers ... */
  42. #define inull (int *)0
  43.  
  44. #define Isyntax   0      /* Integers associated with the SIGNAL ON traps */
  45. #define Ierror    1
  46. #define Ihalt     2
  47. #define Inovalue  3
  48. #define Ifailure  4
  49. #define Inotready 5
  50. #define Imax      6
  51.  
  52. #define Tclauses    1    /* The bit values for the various TRACE facilities */
  53. #define Tlabels     2
  54. #define Tresults    4
  55. #define Tintermed   8
  56. #define Tcommands  16
  57. #define Terrors    32
  58. #define Tfailures  64
  59. #define Tinteract 128
  60.  
  61. /* valid flag values for RexxStartProgram */
  62. #define RXMAIN      1   /* Coming from main(). */
  63. #define RXVERSION   2   /* Print version.  Exit unless another flag is set. */
  64. #define RXOPTIONX   4   /* Do not add file extension; ignore first line. */
  65. #define RXEXITS     8   /* Preserve previous exits. */
  66. #define RXDIGITS   16   /* Preserve previous NUMERIC DIGITS. */
  67. #define RXSTUFF    32   /* Stuff the stack just before it is terminated. */
  68.  
  69. #define Einit      -1   /* Initialisation error */
  70. #define Ehalt       4   /* Program interrupted */
  71. #define Emem        5   /* Machine storage exhausted */
  72. #define Elcomm      6   /* Unmatched '/*' */
  73. #define Equote      6   /* Unmatched quote */
  74. #define Enowhen     7   /* Expected WHEN */
  75. #define Eselect     7   /* Expected OTHERWISE */
  76. #define Ethen       8   /* Unexpected THEN */
  77. #define Ewhen       9   /* Unexpected WHEN */
  78. #define Eend       10   /* Unexpected or unmatched END */
  79. #define Echar      13   /* Invalid character in program */
  80. #define Enoend     14   /* Incomplete DO/SELECT/IF */
  81. #define Eprogend   14
  82. #define Ebin       15   /* Invalid binary constant */
  83. #define Ehex       15   /* Invalid hexadecimal constant */
  84. #define Elabel     16   /* Label not found */
  85. #define Eprocedure 17   /* Unexpected PROCEDURE */
  86. #define Enothen    18   /* Expected THEN */
  87. #define Enostring  19   /* String or symbol expected */
  88. #define Enosymbol  20   /* Symbol expected */
  89. #define Exend      21   /* Invalid data on end of clause */
  90. #define Etrace     24   /* Invalid TRACE request */
  91. #define Eform      25   /* Invalid subkeyword found */
  92. #define Etrap      25
  93. #define Enonint    26   /* Invalid whole number */
  94. #define Erange     26
  95. #define Exdo       27   /* Invalid DO syntax */
  96. #define Eleave     28   /* Invalid LEAVE or ITERATE */
  97. #define Elong      30   /* Symbol too long */
  98. #define Ename      31   /* Name starts with number or '.' */
  99. #define Ebadexpr   35   /* Invalid expression */
  100. #define Eassign    35
  101. #define Elpar      36   /* Unmatched '(' */
  102. #define Ecomma     37   /* Unexpected comma */
  103. #define Erpar      37   /* Unexpected ')' */
  104. #define Eparse     38   /* Invalid template */
  105. #define Eopstk     39   /* Evaluation stack overflow */
  106. #define Eargs      40
  107. #define Ecall      40   /* Incorrect call to routine */
  108. #define Eformat    40
  109. #define Enoarg     40
  110. #define Enum       41   /* Bad arithmetic conversion */
  111. #define Edivide    42
  112. #define Eoflow     42   /* Arithmetic overflow or underflow */
  113. #define Eundef     43   /* Routine not found */
  114. #define Enoresult  44   /* Function did not return data */
  115. #define Ereturn    45   /* No data specified on function RETURN */
  116. #define Exlabel    47   /* Unexpected label */
  117. #define Esys       48   /* Failure in system service */
  118. #define Elost      49   /* Implementation error */
  119. #define Eincalled  50   /* Error in called routine */
  120. #define Enovalue   80   /* No-value error */
  121. #define Eexist     81   /* Use of an un-implemented feature! */
  122. #define Esyntax    82   /* Syntax error */
  123. #define Elabeldot  83   /* Label ends with '.' */
  124. #define Emanyargs  84   /* Too many arguments (> 30) */
  125. #define Eerror     85   /* command returned error */
  126. #define Efailure   86   /* command returned failure */
  127. #define Enotready  87   /* I/O operation raised "notready" error */
  128. #define Ercomm     88   /* Unexpected '* /' */
  129. #define Esig       89   /* Interpreter stopped because of a signal */
  130. #define Eeof       99   /* End of file */
  131. #define Eerrno    100   /* errortext(rc+Eerrno) gives the IO error for rc */
  132. #define Ebounds   200   /* File position was out of bounds */
  133. #define Eseek     201   /* Reposition attempted on transient stream */
  134. #define Eaccess   202   /* Write attempted on a read-only stream */
  135. #define Eread     203   /* Read attempted on a write-only stream */
  136.  
  137. #define numwords 50     /* How many tokens are below */
  138. #define Command -102    /* "Command" tokens are strictly less than this */
  139.  
  140. #define SAY       -128  /* The various tokens */
  141. #define SAYN      -127  /*  - in the same order as in words[] */
  142. #define DO        -126
  143. #define END       -125
  144. #define IF        -124
  145. #define ELSE      -123
  146. #define SELECT    -122
  147. #define WHEN      -121
  148. #define OPTIONS   -120
  149. #define PARSE     -119
  150. #define PUSH      -118
  151. #define QUEUE     -117
  152. #define EXIT      -116
  153. #define RETURN    -115
  154. #define CALL      -114
  155. #define SIGNAL    -113
  156. #define ITERATE   -112
  157. #define LEAVE     -111
  158. #define INTERPRET -110
  159. #define TRACE     -109
  160. #define OTHERWISE -108
  161. #define NOP       -107
  162. #define PROCEDURE -106
  163. #define ADDRESS   -105
  164. #define NUMERIC   -104
  165. #define DROP      -103
  166. #define THEN      -102
  167. #define PULL      -101
  168. #define ARG       -100
  169. #define SOURCE    -99
  170. #define VAR       -98
  171. #define VERSION   -97
  172. #define LINEIN    -96
  173. #define VALUE     -95
  174. #define WITH      -94
  175. #define UPPER     -93
  176. #define TO        -92
  177. #define BY        -91
  178. #define FOR       -90
  179. #define FOREVER   -89
  180. #define WHILE     -88
  181. #define UNTIL     -87
  182. #define ON        -86
  183. #define OFF       -85
  184. #define DIGITS    -84
  185. #define FUZZ      -83
  186. #define FORM      -82
  187. #define EXPOSE    -81
  188. #define HIDE      -80
  189. #define NAME      -79
  190.  
  191. #define LABEL     -50  /* equals NOP; inserted instead of a label */
  192.  
  193. #define SYMBOL    -16 /*240*/            /* lowest symbol number */
  194. #define CONCAT    -15 /*241*/ /* ||  */  /* The various symbolic tokens */
  195. #define LXOR      -14 /*242*/ /* &&  */
  196. #define EQU       -13 /*243*/ /* ==  */
  197. #define LEQ       -12 /*244*/ /* <=  */
  198. #define GEQ       -11 /*245*/ /* >=  */
  199. #define NEQ       -10 /*246*/ /* \=  */
  200. #define NNEQ      -9  /*247*/ /* \== */
  201. #define MOD       -8  /*248*/ /* //  */
  202. #define LESS      -7  /*249*/ /* <<  */
  203. #define GRTR      -6  /*250*/ /* >>  */
  204. #define LLEQ      -5  /*251*/ /* <<= */
  205. #define GGEQ      -4  /*252*/ /* >>= */
  206. #define POWER     -3  /*253*/ /* **  */
  207.  
  208. #define Cconcat   0x7c7c    /* || */     /* ASCII values of these operators */
  209. #define Cxor      0x2626    /* && */
  210. #define Cequ      0x3d3d    /* == */
  211. #define Cleq1     0x3c3d    /* <= */
  212. #define Cleq2     0x5c3e    /* \> */
  213. #define Cgeq1     0x3e3d    /* >= */
  214. #define Cgeq2     0x5c3c    /* \< */
  215. #define Cneq1     0x5c3d    /* \= */
  216. #define Cneq2     0x3c3e    /* <> */
  217. #define Cneq3     0x3e3c    /* >< */
  218. #define Cnneq     0x5c3d3d  /* \== */
  219. #define Cmod      0x2f2f    /* // */
  220. #define Cless     0x3c3c    /* << */
  221. #define Cgrtr     0x3e3e    /* >> */
  222. #define Clleq1    0x3c3c3d  /* <<= */
  223. #define Clleq2    0x5c3e3e  /* \>> */
  224. #define Cggeq1    0x3e3e3d  /* >>= */
  225. #define Cggeq2    0x5c3c3c  /* \<< */
  226. #define Cpower    0x2a2a    /* ** */
  227.  
  228. #define OPpower   0 /* **        */ /* The various operator numbers (used   */
  229. #define OPmul     1 /* *         */ /* by scanning() and related functions) */
  230. #define OPdiv     2 /* /         */
  231. #define OPadd     3 /* + (binary)*/
  232. #define OPsub     4 /* - (binary)*/
  233. #define OPspc     5 /* space     */
  234. #define OPcat     6 /* ||        */
  235. #define OPequ     7 /* =         */
  236. #define OPeequ    8 /* ==        */
  237. #define OPless    9 /* <         */
  238. #define OPleq    10 /* <=        */
  239. #define OPgrtr   11 /* >         */
  240. #define OPgeq    12 /* >=        */
  241. #define OPneq    13 /* \=        */
  242. #define OPand    14 /* &         */
  243. #define OPxor    15 /* &&        */
  244. #define OPor     16 /* |         */
  245. #define OPidiv   17 /* %         */
  246. #define OPmod    18 /* //        */
  247. #define OPnneq   19 /* \==       */
  248. #define OPlless  20 /* <<        */
  249. #define OPggrtr  21 /* >>        */
  250. #define OPlleq   22 /* <<=       */
  251. #define OPggeq   23 /* >>=       */
  252. #define OPneg    24 /* - (unary) */
  253. #define OPplus   25 /* + (unary) */
  254. #define OPnot    26 /* \         */
  255.  
  256. typedef void (*sighandler)();
  257.  
  258. typedef struct _program {   /* Structure for the preprocessed program */
  259.    int num;                 /* Line number in source (for traceback) */
  260.    char *source;            /* Start of this statement within the source */
  261.    char *sourcend;          /* End of same */
  262.    int related;             /* A related statement number (if any) */
  263.    char *line;              /* The program line to be interpreted */
  264. } program;
  265.    
  266. struct procstack {  /* A program stack entry for an external procedure call */
  267.    int stmt;        /* Statement number of call instruction */
  268.    char *csp;       /* Old calculator stack */
  269.    int ecsp;        /* Old calculator stack end */
  270.    int csl;         /* Old calculator stack length */
  271.    char trc;        /* Old trace flag */
  272.    char tim;        /* Old timestamp flag */
  273.    char form;       /* Old NUMERIC FORM */
  274.                     /* Some padding (one byte, probably) */
  275.    int digits;      /* Old NUMERIC DIGITS */
  276.    int fuzz;        /* Old NUMERIC FUZZ */
  277.    long mic;        /* Old timestamp microseconds */
  278.    long sec;        /* Old timestamp seconds */
  279.    int address1;    /* Old current environment */
  280.    int address2;    /* Old alternate environment */
  281.    program *prg;    /* Old tokenised program */
  282.    int stmts;       /* Old number of statements */
  283.    int lines;       /* Old number of program lines */
  284.    char **src;      /* Old source */
  285.    char *lab;       /* Old labels */
  286. #ifdef POINTER64
  287.    int dummy;       /* Artificial padding */
  288. #endif
  289.    int lev;         /* Old pstack level */
  290.    int len;         /* Length of this stack entry */
  291.    int type;        /* Type = 13 for external procedure call */
  292. };
  293.  
  294. struct procstack2 { /* A program stack entry for a procedure call */
  295.    int stmt;        /* Statement number of call instruction */
  296.    char *csp;       /* Old calculator stack */
  297.    int ecsp;        /* Old calculator stack end */
  298.    int csl;         /* Old calculator stack length */
  299.    char trc;        /* Old trace flag */
  300.    char tim;        /* Old timestamp flag */
  301.    char form;       /* Old NUMERIC FORM */
  302.                     /* Some padding (one byte, probably) */
  303.    int digits;      /* Old NUMERIC DIGITS */
  304.    int fuzz;        /* Old NUMERIC FUZZ */
  305.    long mic;        /* Old timestamp microseconds */
  306.    long sec;        /* Old timestamp seconds */
  307.    int address1;    /* Old current environment */
  308.    int address2;    /* Old alternate environment */
  309.    program *prg;    /* The current interpreted string or the current program */
  310. #ifdef POINTER64
  311.    int dummy;       /* Artificial padding */
  312. #endif
  313.    int stmts;       /* Number of statements in the above */
  314.    int len;         /* Length of this stack entry */
  315.    int type;        /* Type = 11 for internal procedure call;  */
  316. };                  /*        12 after a PROCEDURE instruction */
  317.  
  318. struct minstack {   /* A minimum program stack entry */
  319.    int stmt;        /* Statement where block started */
  320. #ifdef POINTER64
  321.    int dummy;       /* Artificial padding */
  322. #endif
  323.    char *pos;       /* Pointer to statement (used to find the WHILE or UNTIL)*/
  324.    int len;         /* Length of this stack entry */
  325.    int type;        /* Type =  0 for DO;  */
  326. };                  /*         8 for DO WHILE/FOREVER */
  327.                     /*        10 for DO with control variable */
  328.                     /*         2 for SELECT */
  329.  
  330. struct forstack {   /* A program stack entry for the "DO count" instruction */
  331.    int stmt;        /* Statement number of DO instruction */
  332. #ifdef POINTER64
  333.    int dummy1;      /* Artificial padding */
  334. #endif
  335.    char *pos;       /* Pointer to statement (used to find the WHILE or UNTIL)*/
  336. #ifdef POINTER64
  337.    int dummy;       /* More artificial padding */
  338. #endif
  339.    int fornum;      /* Loop counter */
  340.    int len;         /* Length of this stack entry */
  341.    int type;        /* Type = 15 for a "DO count" instruction */
  342. };
  343.  
  344. struct interpstack {/* A program stack entry for the INTERPRET instruction */
  345.    int stmt;        /* Statement number of INTERPRET instruction */
  346.    program *prg;    /* Old tokenised program */
  347. #ifdef POINTER64
  348.    int dummy;       /* Artificial padding */
  349. #endif
  350.    int stmts;       /* Old number of statements */
  351.    int len;         /* Length of this stack entry */
  352.    int type;        /* Type = 14 for an INTERPRET instruction */
  353. };
  354.  
  355. struct interactstack {/* A program stack entry for interactive instructions */
  356.                       /* NB always followed by an interpstack entry */
  357.    int stmt;        /* Statement number of the interruption */
  358.    char *csp;       /* Old calculator stack */
  359.    int ecs;         /* Old calculator stack end pointer */
  360.    int csl;         /* Old calculator stack length */
  361.    int len;         /* Length of this stack entry */
  362.    int type;        /* Type = 16 for interactive instructions */
  363. };
  364.  
  365. struct errorstack { /* A program stack entry for saving a traceback line */
  366.    int stmt;        /* Statement number of the error */
  367.    program *prg;    /* Program where the error occurred */
  368. #ifdef POINTER64
  369.    int dummy;       /* Artificial padding */
  370. #endif
  371.    int stmts;       /* Number of statements in this program */
  372.    int len;         /* Length of this stack entry */
  373.    int type;        /* Type = 20 for saved traceback line */
  374. };
  375.  
  376. struct fileinfo {   /* Structure containing information about an open file */
  377.    FILE *fp;        /* The stream pointer */
  378.    char wr;         /* Whether writing is allowed; -1=write-only */
  379.    char lastwr;     /* Whether the last operation was a write */
  380.    char persist;    /* Whether the file is persistent (i.e. a regular file) */
  381.    long rdpos;      /* The read character position (0-based) */
  382.    int rdline;      /* The read line position, if known (1-based) */
  383.    int rdchars;     /* Whether an incomplete line has been read */
  384.    long wrpos;      /* The write character position (0-based) */
  385.    int wrline;      /* The write line position, if known (1-based) */
  386.    int wrchars;     /* Whether an incomplete line has been written */
  387.    int errnum;      /* Error status for stream('d') */
  388. };
  389.    
  390. typedef struct _hashent { /* Structure containing hash table entry */
  391.    int next;        /* Length of the whole item */
  392.    int less;        /* Pointer to left child */
  393.    int grtr;        /* Pointer to right child */
  394.    void *value;     /* Pointer to value */
  395. } hashent;
  396.  
  397. typedef struct _varent {       /* a variable table entry */
  398.    int next;                   /* length of structure */
  399.    int less;                   /* position of left child within tree */
  400.    int grtr;                   /* position of right child within tree */
  401.    int namelen;                /* length of variable's name */
  402.    int valalloc;               /* length allocated to variable's value */
  403.    int vallen;                 /* actual length of variable's value */
  404. } varent;
  405.  
  406. typedef struct _funcinfo { /* Structure containing info about a function */
  407.    void *dlhandle;         /* Handle from dlopen(), if this is the "main" fn */
  408.    int (*dlfunc)();        /* Address of the function */
  409.    char *name;             /* file name of a previously found function*/
  410.    int saa;                /* calling sequence */
  411. } funcinfo;
  412.  
  413. typedef struct _dictionary {/* Structure containing a list of REXX functions */
  414.    char *name;              /* REXX name of function */
  415.    int (*function)();       /* Address of function */
  416. } dictionary;
  417.  
  418. #endif /* !_const_h */
  419.