home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / rexx / imc / rexx-imc.5 / globals.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-25  |  7.9 KB  |  129 lines

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