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

  1. /* The global variables of REXX/imc            (C) Ian Collier 1993 */
  2.  
  3. #include<stdio.h>
  4. #include<setjmp.h>
  5. #include<sys/types.h>
  6. #include<sys/time.h>
  7. #include"const.h"
  8. #include"globals.h"
  9. #define INCL_RXSYSEXIT
  10. #include"rexxsaa.h"
  11.  
  12. char fname[maxvarname];        /* the current file name */
  13. char extension[maxextension];  /* the default file extension */
  14. int extlen;                    /* and its length */
  15. int lines;                     /* number of lines in current source */
  16. int stmts;                     /* number of statements in current program*/
  17. char **source=0;               /* the source of the current program */
  18. program *prog=0;               /* the current program, tokenised */
  19. char *labelptr=cnull;          /* start of label table */
  20. int *varstk=inull;             /* offsets to levels in variable table */
  21. unsigned varstklen;            /* number of elements allocated to varstk */
  22. int varstkptr;                 /* current level number */
  23. char *vartab=cnull;            /* start of variable table */
  24. unsigned vartablen;            /* space allocated to vartab */
  25. char *cstackptr=cnull;         /* start of calculator stack */
  26. unsigned ecstackptr;           /* length of calculator stack */
  27. unsigned cstacklen;            /* space allocated to calculator stack */
  28. char *workptr=cnull;           /* start of workspace */
  29. unsigned eworkptr;             /* amount of workspace used */
  30. unsigned worklen;              /* space allocated to workspace */
  31. char *pstackptr;               /* start of program stack */
  32. unsigned epstackptr;           /* length of program stack */
  33. unsigned pstacklen;            /* space allocated to program stack */
  34. int pstacklev=0;               /* program stack level within current func */
  35. char *hashptr[3]={0,0,0};      /* pointers to 3 hash tables */
  36. unsigned ehashptr[3]={0,0,0};  /* lengths of hash tables */
  37. unsigned hashlen[3]={0,0,0};   /* space allocated to hash tables */
  38. struct sigstruct *sgstack;     /* contexts of all calls to interpreter() */
  39.                                /* and which signals to catch */
  40. unsigned sigstacklen=0;        /* number of elements allocated to sgstack */
  41. int delayed[Imax];             /* Which signals are pending action */
  42. char *sigdata[Imax]={0,0,0,0,0,0}; /* Descriptions for pending signals */
  43. jmp_buf interactbuf;           /* context of interactive trace routine */
  44. jmp_buf *exitbuf;              /* where to go on exit */
  45. int interplev=-1;              /* nesting level of interpreter() */
  46. int interact= -1;              /* interplev of interactive trace, or -1 */
  47. int interactmsg=0;             /* Whether to emit message at interactive() */
  48. int ppc=-1;                    /* Statement number being interpreted */
  49. int oldppc;                    /* saved position in case of error */
  50. int newppc;                    /* statement to jump to */
  51. char **curargs;                /* current arguments, for ARG() */
  52. int *curarglen;                /* lengths of current arguments */
  53. char *errordata=cnull;         /* data to print after error message */
  54. int precision=9;               /* NUMERIC DIGITS */
  55. int fuzz=9;                    /* NUMERIC DIGITS minus NUMERIC FUZZ */
  56. char numform=0;                /* 0=SCIENTIFIC, 1=ENGINEERING */
  57. char trcflag=Tfailures;        /* what to trace */
  58. char trcresult=0;              /* nesting level of scanning() */
  59. char otrcflag;                 /* temporary store for trace flag */
  60. char trclp;                    /* whether to get input in interactive mode */
  61. char timeflag=0;               /* bit 0: used elapsed time counter */
  62.                                /* bit 1: timestamp in operation */
  63.                                /* bit 2: used random number generator */
  64. long secs;long microsecs;      /* timestamp when TIME(r) was last called */
  65. struct timeval timestamp;      /* the timestamp, if in operation */
  66. int address0=0;                /* The initial environment */
  67. int address1=0;                /* The current environment */
  68. int address2=0;                /* The alternate environment */
  69. char *rxpath;                  /* where to find libraries if not in REXXLIB */
  70. FILE *ttyin,*ttyout;           /* access to the terminal */
  71. char *pull=cnull;              /* storage used for input */
  72. unsigned pulllen=0;            /* space allocated for pull */
  73. char *returnval;               /* value returned by EXIT */
  74. int returnlen;                 /* length of that value */
  75. char *returnfree;              /* what to free after returnval has been used */
  76. int rxstacksock;               /* fd number of stack socket */
  77. char *varnamebuf;              /* workspace for evaluating variable names */
  78. int varnamelen;                /* amount of memory allocated for varnamebuff */
  79. FILE *traceout=0;              /* Where to send trace output */
  80. int lasterror=0;               /* The last error which occurred on I/O */
  81. int setrcflag=0;               /* flag for "options setrc" */
  82. int exposeflag=0;              /* flag for "options expose" */
  83. int sigpipeflag=0;             /* flag for "options sigpipe" */
  84. varent *nextvar=0;             /* next variable for RXSHV_NEXTV */
  85.  
  86.  
  87. long (*exitlist[RXEXITNUM])(); /* list of exit addresses */
  88.  
  89. char *conditions[]=   /* condition names in the same order as their I-values */
  90.          {"SYNTAX","ERROR","HALT","NOVALUE","FAILURE","NOTREADY"};
  91.  
  92. /* Character classification tables */
  93.  
  94. /*                0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F       *
  95.                 { ., ., ., ., ., ., ., ., .,\t,\n, ., .,\r, ., .,  * 0 *
  96.                   ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., .,  * 1 *
  97.                    , !, ", #, $, %, &, ', (, ), *, +, ,, -, ., /,  * 2 *
  98.                   0, 1, 2, 3, 4, 5, 6, 7, 8, 9, :, ;, <, =, >, ?,  * 3 *
  99.                   @, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O,  * 4 *
  100.                   P, Q, R, S, T, U, V, W, X, Y, Z, [, \, ], ^, _,  * 5 *
  101.                   `, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o,  * 6 *
  102.                   p, q, r, s, t, u, v, w, x, y, z, {, |, }, ~, .}; * 7 */
  103.  
  104. /* Table of types: -2 invalid, -1 tokenisable special char, 1 symbol char,
  105.                     2 number, 0 other */
  106. /*                0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F       */
  107.  int types[256]={-2,-2,-2,-2,-2,-2,-2,-2,-2, 0,-2,-2,-2, 0,-2,-2, /* 0 */
  108.                  -2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2, /* 1 */
  109.                   0, 1, 0, 1, 1, 0,-1, 0, 0, 0,-1, 0, 0, 0, 1,-1, /* 2 */
  110.                   2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0,-1,-1,-1, 1, /* 3 */
  111.                   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 4 */
  112.                   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,-2,-1,-2,-1, 1, /* 5 */
  113.                  -2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 6 */
  114.                   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,-2,-1,-2,-2,-2, /* 7 */
  115.                  -2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2, /* 8 */
  116.                  -2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2, /* 9 */
  117.                  -2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2, /* A */
  118.                  -2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2, /* B */
  119.                  -2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2, /* C */
  120.                  -2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2, /* D */
  121.                  -2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2, /* E */
  122.                  -2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2};/* F */
  123.  
  124. /* Alphanum table: 1 letter, 2 number, 3 dot, 0 other */
  125. /*                0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F       */
  126.  int alphs[256]={ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0 */
  127.                   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 1 */
  128.                   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, /* 2 */
  129.                   2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, /* 3 */
  130.                   0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 4 */
  131.                   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, /* 5 */
  132.                   0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 6 */
  133.                   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0};/* 7 */
  134.  
  135. /* Symbol table: 0 if invalid in a simple symbol, -1 if valid except at
  136.                  start, 1 otherwise */
  137. /*                0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F       */
  138.  int symbs[256]={ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0 */
  139.                   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 1 */
  140.                   0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 2 */
  141.                  -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, /* 3 */
  142.                   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 4 */
  143.                   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, /* 5 */
  144.                   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 6 */
  145.                   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};/* 7 */
  146.  
  147.