home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 5 / FreshFish_July-August1994.bin / bbs / gnu / flex-2.4.6-src.lha / src / amiga / flex-2.4.6 / flexdef.h < prev    next >
C/C++ Source or Header  |  1994-01-04  |  31KB  |  903 lines

  1. /* flexdef - definitions file for flex */
  2.  
  3. /*-
  4.  * Copyright (c) 1990 The Regents of the University of California.
  5.  * All rights reserved.
  6.  *
  7.  * This code is derived from software contributed to Berkeley by
  8.  * Vern Paxson.
  9.  * 
  10.  * The United States Government has rights in this work pursuant
  11.  * to contract no. DE-AC03-76SF00098 between the United States
  12.  * Department of Energy and the University of California.
  13.  *
  14.  * Redistribution and use in source and binary forms are permitted provided
  15.  * that: (1) source distributions retain this entire copyright notice and
  16.  * comment, and (2) distributions including binaries display the following
  17.  * acknowledgement:  ``This product includes software developed by the
  18.  * University of California, Berkeley and its contributors'' in the
  19.  * documentation or other materials provided with the distribution and in
  20.  * all advertising materials mentioning features or use of this software.
  21.  * Neither the name of the University nor the names of its contributors may
  22.  * be used to endorse or promote products derived from this software without
  23.  * specific prior written permission.
  24.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  25.  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  26.  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  27.  */
  28.  
  29. /* @(#) $Header: flexdef.h,v 1.2 94/01/04 14:33:14 vern Exp $ (LBL) */
  30.  
  31. #include <stdio.h>
  32. #include <ctype.h>
  33.  
  34. #if HAVE_STRING_H
  35. #include <string.h>
  36. #else
  37. #include <strings.h>
  38. #endif
  39.  
  40. #if __STDC__
  41. #include <stdlib.h>
  42. #endif
  43.  
  44. /* Always be prepared to generate an 8-bit scanner. */
  45. #define CSIZE 256
  46. #define Char unsigned char
  47.  
  48. /* Size of input alphabet - should be size of ASCII set. */
  49. #ifndef DEFAULT_CSIZE
  50. #define DEFAULT_CSIZE 128
  51. #endif
  52.  
  53. #ifndef PROTO
  54. #ifdef __STDC__
  55. #define PROTO(proto) proto
  56. #else
  57. #define PROTO(proto) ()
  58. #endif
  59. #endif
  60.  
  61. #ifdef VMS
  62. #define unlink delete
  63. #define SHORT_FILE_NAMES
  64. #endif
  65.  
  66. #ifdef MS_DOS
  67. #define SHORT_FILE_NAMES
  68. #endif
  69.  
  70.  
  71. /* Maximum line length we'll have to deal with. */
  72. #define MAXLINE 2048
  73.  
  74. #ifndef MIN
  75. #define MIN(x,y) ((x) < (y) ? (x) : (y))
  76. #endif
  77. #ifndef MAX
  78. #define MAX(x,y) ((x) > (y) ? (x) : (y))
  79. #endif
  80. #ifndef ABS
  81. #define ABS(x) ((x) < 0 ? -(x) : (x))
  82. #endif
  83.  
  84.  
  85. /* ANSI C does not guarantee that isascii() is defined */
  86. #ifndef isascii
  87. #define isascii(c) ((c) <= 0177)
  88. #endif
  89.  
  90.  
  91. #define true 1
  92. #define false 0
  93.  
  94.  
  95. /* Special chk[] values marking the slots taking by end-of-buffer and action
  96.  * numbers.
  97.  */
  98. #define EOB_POSITION -1
  99. #define ACTION_POSITION -2
  100.  
  101. /* Number of data items per line for -f output. */
  102. #define NUMDATAITEMS 10
  103.  
  104. /* Number of lines of data in -f output before inserting a blank line for
  105.  * readability.
  106.  */
  107. #define NUMDATALINES 10
  108.  
  109. /* Transition_struct_out() definitions. */
  110. #define TRANS_STRUCT_PRINT_LENGTH 15
  111.  
  112. /* Returns true if an nfa state has an epsilon out-transition slot
  113.  * that can be used.  This definition is currently not used.
  114.  */
  115. #define FREE_EPSILON(state) \
  116.     (transchar[state] == SYM_EPSILON && \
  117.      trans2[state] == NO_TRANSITION && \
  118.      finalst[state] != state)
  119.  
  120. /* Returns true if an nfa state has an epsilon out-transition character
  121.  * and both slots are free
  122.  */
  123. #define SUPER_FREE_EPSILON(state) \
  124.     (transchar[state] == SYM_EPSILON && \
  125.      trans1[state] == NO_TRANSITION) \
  126.  
  127. /* Maximum number of NFA states that can comprise a DFA state.  It's real
  128.  * big because if there's a lot of rules, the initial state will have a
  129.  * huge epsilon closure.
  130.  */
  131. #define INITIAL_MAX_DFA_SIZE 750
  132. #define MAX_DFA_SIZE_INCREMENT 750
  133.  
  134.  
  135. /* A note on the following masks.  They are used to mark accepting numbers
  136.  * as being special.  As such, they implicitly limit the number of accepting
  137.  * numbers (i.e., rules) because if there are too many rules the rule numbers
  138.  * will overload the mask bits.  Fortunately, this limit is \large/ (0x2000 ==
  139.  * 8192) so unlikely to actually cause any problems.  A check is made in
  140.  * new_rule() to ensure that this limit is not reached.
  141.  */
  142.  
  143. /* Mask to mark a trailing context accepting number. */
  144. #define YY_TRAILING_MASK 0x2000
  145.  
  146. /* Mask to mark the accepting number of the "head" of a trailing context
  147.  * rule.
  148.  */
  149. #define YY_TRAILING_HEAD_MASK 0x4000
  150.  
  151. /* Maximum number of rules, as outlined in the above note. */
  152. #define MAX_RULE (YY_TRAILING_MASK - 1)
  153.  
  154.  
  155. /* NIL must be 0.  If not, its special meaning when making equivalence classes
  156.  * (it marks the representative of a given e.c.) will be unidentifiable.
  157.  */
  158. #define NIL 0
  159.  
  160. #define JAM -1    /* to mark a missing DFA transition */
  161. #define NO_TRANSITION NIL
  162. #define UNIQUE -1    /* marks a symbol as an e.c. representative */
  163. #define INFINITY -1    /* for x{5,} constructions */
  164.  
  165. #define INITIAL_MAX_CCLS 100    /* max number of unique character classes */
  166. #define MAX_CCLS_INCREMENT 100
  167.  
  168. /* Size of table holding members of character classes. */
  169. #define INITIAL_MAX_CCL_TBL_SIZE 500
  170. #define MAX_CCL_TBL_SIZE_INCREMENT 250
  171.  
  172. #define INITIAL_MAX_RULES 100    /* default maximum number of rules */
  173. #define MAX_RULES_INCREMENT 100
  174.  
  175. #define INITIAL_MNS 2000    /* default maximum number of nfa states */
  176. #define MNS_INCREMENT 1000    /* amount to bump above by if it's not enough */
  177.  
  178. #define INITIAL_MAX_DFAS 1000    /* default maximum number of dfa states */
  179. #define MAX_DFAS_INCREMENT 1000
  180.  
  181. #define JAMSTATE -32766    /* marks a reference to the state that always jams */
  182.  
  183. /* Enough so that if it's subtracted from an NFA state number, the result
  184.  * is guaranteed to be negative.
  185.  */
  186. #define MARKER_DIFFERENCE 32000
  187. #define MAXIMUM_MNS 31999
  188.  
  189. /* Maximum number of nxt/chk pairs for non-templates. */
  190. #define INITIAL_MAX_XPAIRS 2000
  191. #define MAX_XPAIRS_INCREMENT 2000
  192.  
  193. /* Maximum number of nxt/chk pairs needed for templates. */
  194. #define INITIAL_MAX_TEMPLATE_XPAIRS 2500
  195. #define MAX_TEMPLATE_XPAIRS_INCREMENT 2500
  196.  
  197. #define SYM_EPSILON (CSIZE + 1)    /* to mark transitions on the symbol epsilon */
  198.  
  199. #define INITIAL_MAX_SCS 40    /* maximum number of start conditions */
  200. #define MAX_SCS_INCREMENT 40    /* amount to bump by if it's not enough */
  201.  
  202. #define ONE_STACK_SIZE 500    /* stack of states with only one out-transition */
  203. #define SAME_TRANS -1    /* transition is the same as "default" entry for state */
  204.  
  205. /* The following percentages are used to tune table compression:
  206.  
  207.  * The percentage the number of out-transitions a state must be of the
  208.  * number of equivalence classes in order to be considered for table
  209.  * compaction by using protos.
  210.  */
  211. #define PROTO_SIZE_PERCENTAGE 15
  212.  
  213. /* The percentage the number of homogeneous out-transitions of a state
  214.  * must be of the number of total out-transitions of the state in order
  215.  * that the state's transition table is first compared with a potential 
  216.  * template of the most common out-transition instead of with the first
  217.  * proto in the proto queue.
  218.  */
  219. #define CHECK_COM_PERCENTAGE 50
  220.  
  221. /* The percentage the number of differences between a state's transition
  222.  * table and the proto it was first compared with must be of the total
  223.  * number of out-transitions of the state in order to keep the first
  224.  * proto as a good match and not search any further.
  225.  */
  226. #define FIRST_MATCH_DIFF_PERCENTAGE 10
  227.  
  228. /* The percentage the number of differences between a state's transition
  229.  * table and the most similar proto must be of the state's total number
  230.  * of out-transitions to use the proto as an acceptable close match.
  231.  */
  232. #define ACCEPTABLE_DIFF_PERCENTAGE 50
  233.  
  234. /* The percentage the number of homogeneous out-transitions of a state
  235.  * must be of the number of total out-transitions of the state in order
  236.  * to consider making a template from the state.
  237.  */
  238. #define TEMPLATE_SAME_PERCENTAGE 60
  239.  
  240. /* The percentage the number of differences between a state's transition
  241.  * table and the most similar proto must be of the state's total number
  242.  * of out-transitions to create a new proto from the state.
  243.  */
  244. #define NEW_PROTO_DIFF_PERCENTAGE 20
  245.  
  246. /* The percentage the total number of out-transitions of a state must be
  247.  * of the number of equivalence classes in order to consider trying to
  248.  * fit the transition table into "holes" inside the nxt/chk table.
  249.  */
  250. #define INTERIOR_FIT_PERCENTAGE 15
  251.  
  252. /* Size of region set aside to cache the complete transition table of
  253.  * protos on the proto queue to enable quic