home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / OS2_LEX.ZIP / SYSTEM.H < prev    next >
C/C++ Source or Header  |  1989-10-09  |  3KB  |  115 lines

  1. /*
  2.  * system.h -- system configuration definitions for lex.c
  3.  *
  4.  * Modified 02-Dec-80 Bob Denny -- Conditionalize debug code for smaller size
  5.  *                                 Turn on debug code when overlaid.
  6.  *          03-Dec-80 Bob Denny -- Change allocations for moves, nfa's and
  7.  *                                  dfa's for RT-11. Try these for RSX if
  8.  *                                  you overlay the same way.
  9.  *          28-May-81 Bob Denny -- Change allocations for both RT and RSX.
  10.  *                                  Overlay is same. Debug code adds little
  11.  *                                  task space. Delete externs which caused
  12.  *                                  TKB to barf.
  13.  *          28-Aug-81 Bob Denny -- Add extern int sflag for "-s" support.
  14.  *          30-Oct-82 Bob Denny -- Change allocations for RSX.
  15.  *          15-Apr-83 Bob Denny -- Add big allocations for VAX-11 C
  16.  *            20-Nov-83 Scott Guthery -- Adapt for IBM PC & DeSmet C
  17.  */
  18.  
  19. #define DEBUG    YES
  20.  
  21. /*
  22.  * Original allocations.
  23.  */
  24. #define NCHARS  0400        /* Size of character set */
  25. #define NCPW       2        /* # characters per word */
  26. #define NBPC       8        /* # bits per character */
  27. #define NBPW  (NCPW*NBPC)    /* # bits per word */
  28.  
  29. #define MAXNFA  1200        /* Number of NFA states */
  30. #define MAXDFA  1500        /* Number of DFA states */
  31. #define NTRANS   128        /* Number of translations */
  32. #define NCCLS     50        /* Number of character classes */
  33. #define NNEXT   4000        /* Size of dfa move vectors (later: allocate) */
  34.  
  35. /*
  36.  * Special node characters.
  37.  */
  38. #define CCL     NCHARS          /* One of a character class */
  39. #define EPSILON NCHARS+1        /* Transition on epsilon */
  40. #define FIN     NCHARS+2        /* Final state; NFA */
  41.  
  42. /*
  43.  * Set of state numbers (dfa state name).
  44.  */
  45. struct  set {
  46.         struct  set     *s_next;
  47.         struct  dfa     *s_state;       /* pointer into dfa array  */
  48.         struct  set     *s_group;       /* pointer to owning group (dfamin) */
  49.         int     s_final;                /* nf state which matches  */
  50.         char    s_flag;                 /* see below */
  51.         int     s_look;                 /* look-ahead bits */
  52.         int     s_len;                  /* number of elements in set */
  53.         struct  nfa     *s_els[1];
  54. };
  55.  
  56. /*
  57.  * State entry
  58.  */
  59. struct  nfa {
  60.         int     n_char;
  61.         char    *n_ccl;
  62.         char    n_flag;
  63.         char    n_look;         /* lookahead index */
  64.         struct  nfa     *n_succ[2];
  65.         struct  trans   *n_trans;
  66. };
  67.  
  68. /*
  69.  * DFA transition entry.
  70.  */
  71. struct  move {
  72.         struct  set     *m_next;
  73.         struct  dfa     *m_check;
  74. };
  75.  
  76. /*
  77.  * Structure of DFA vector.
  78.  */
  79. struct  dfa {
  80.         struct  set     *df_name;
  81.         struct  move    *df_base;
  82.         struct  move    *df_max;
  83.         struct  dfa     *df_default;
  84.         int     df_ntrans;
  85. };
  86.  
  87. /*
  88.  * s_flag values for DFA node
  89.  */
  90. #define LOOK    01      /* Lookahead mark */
  91. #define ADDED   02      /* DFA construction mark */
  92. #define FLOOK   04      /* Mark on final state of lookahead translation */
  93.  
  94. /*
  95.  * Flag used to print node
  96.  */
  97. #define NPRT    010     /* NFA node printed */
  98.  
  99. /*
  100.  * Transition set.
  101.  */
  102. struct  xset {
  103.         struct  set     *x_set;
  104.         char    x_char;
  105.         char    x_defsame;
  106. };
  107.  
  108. /*
  109.  * Translations
  110.  */
  111. struct  trans {
  112.         struct  nfa     *t_start;
  113.         struct  nfa     *t_final;
  114. };
  115.