This is Unofficial EPICS BASE Doxygen Site
flexdef.h File Reference
#include <stdio.h>
#include <string.h>
#include <stddef.h>
#include <stdlib.h>
#include <ctype.h>
#include <osiUnistd.h>
+ Include dependency graph for flexdef.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  hash_entry
 
union  dfaacc_union
 

Macros

#define NORETURN
 
#define FLEX_8_BIT_CHARS
 
#define CSIZE   256
 
#define Char   unsigned char
 
#define DEFAULT_CSIZE   128
 
#define MAXLINE   BUFSIZ
 
#define FILENAMESIZE   1024
 
#define min(x, y)   ((x) < (y) ? (x) : (y))
 
#define max(x, y)   ((x) > (y) ? (x) : (y))
 
#define true   1
 
#define false   0
 
#define DEFAULT_SKELETON_FILE   "flex.skel"
 
#define EOB_POSITION   -1
 
#define ACTION_POSITION   -2
 
#define NUMDATAITEMS   10
 
#define NUMDATALINES   10
 
#define TRANS_STRUCT_PRINT_LENGTH   15
 
#define FREE_EPSILON(state)
 
#define SUPER_FREE_EPSILON(state)
 
#define INITIAL_MAX_DFA_SIZE   750
 
#define MAX_DFA_SIZE_INCREMENT   750
 
#define YY_TRAILING_MASK   0x2000
 
#define YY_TRAILING_HEAD_MASK   0x4000
 
#define MAX_RULE   (YY_TRAILING_MASK - 1)
 
#define NIL   0
 
#define JAM   -1 /* to mark a missing DFA transition */
 
#define NO_TRANSITION   NIL
 
#define UNIQUE   -1 /* marks a symbol as an e.c. representative */
 
#define INFINITY   -1 /* for x{5,} constructions */
 
#define INITIAL_MAX_CCLS   100 /* max number of unique character classes */
 
#define MAX_CCLS_INCREMENT   100
 
#define INITIAL_MAX_CCL_TBL_SIZE   500
 
#define MAX_CCL_TBL_SIZE_INCREMENT   250
 
#define INITIAL_MAX_RULES   100 /* default maximum number of rules */
 
#define MAX_RULES_INCREMENT   100
 
#define INITIAL_MNS   2000 /* default maximum number of nfa states */
 
#define MNS_INCREMENT   1000 /* amount to bump above by if it's not enough */
 
#define INITIAL_MAX_DFAS   1000 /* default maximum number of dfa states */
 
#define MAX_DFAS_INCREMENT   1000
 
#define JAMSTATE   -32766 /* marks a reference to the state that always jams */
 
#define MARKER_DIFFERENCE   32000
 
#define MAXIMUM_MNS   31999
 
#define INITIAL_MAX_XPAIRS   2000
 
#define MAX_XPAIRS_INCREMENT   2000
 
#define INITIAL_MAX_TEMPLATE_XPAIRS   2500
 
#define MAX_TEMPLATE_XPAIRS_INCREMENT   2500
 
#define SYM_EPSILON   (CSIZE + 1) /* to mark transitions on the symbol epsilon */
 
#define INITIAL_MAX_SCS   40 /* maximum number of start conditions */
 
#define MAX_SCS_INCREMENT   40 /* amount to bump by if it's not enough */
 
#define ONE_STACK_SIZE   500 /* stack of states with only one out-transition */
 
#define SAME_TRANS   -1 /* transition is the same as "default" entry for state */
 
#define PROTO_SIZE_PERCENTAGE   15
 
#define CHECK_COM_PERCENTAGE   50
 
#define FIRST_MATCH_DIFF_PERCENTAGE   10
 
#define ACCEPTABLE_DIFF_PERCENTAGE   50
 
#define TEMPLATE_SAME_PERCENTAGE   60
 
#define NEW_PROTO_DIFF_PERCENTAGE   20
 
#define INTERIOR_FIT_PERCENTAGE   15
 
#define PROT_SAVE_SIZE   2000
 
#define MSP   50 /* maximum number of saved protos (protos on the proto queue) */
 
#define MAX_XTIONS_FULL_INTERIOR_FIT   4
 
#define MAX_ASSOC_RULES   100
 
#define BAD_SUBSCRIPT   -32767
 
#define MAX_SHORT   32766
 
#define NAME_TABLE_HASH_SIZE   101
 
#define START_COND_HASH_SIZE   101
 
#define CCL_HASH_SIZE   101
 
#define REALLY_NOT_DETERMINED   0
 
#define REALLY_USED   1
 
#define REALLY_NOT_USED   2
 
#define STATE_NORMAL   0x1
 
#define STATE_TRAILING_CONTEXT   0x2
 
#define RULE_NORMAL   0
 
#define RULE_VARIABLE   1
 
#define allocate_integer_array(size)   (int *) allocate_array( size, sizeof( int ) )
 
#define reallocate_integer_array(array, size)   (int *) reallocate_array( (void *) array, size, sizeof( int ) )
 
#define allocate_int_ptr_array(size)   (int **) allocate_array( size, sizeof( int * ) )
 
#define allocate_char_ptr_array(size)   (char **) allocate_array( size, sizeof( char * ) )
 
#define allocate_dfaacc_union(size)
 
#define reallocate_int_ptr_array(array, size)   (int **) reallocate_array( (void *) array, size, sizeof( int * ) )
 
#define reallocate_char_ptr_array(array, size)   (char **) reallocate_array( (void *) array, size, sizeof( char * ) )
 
#define reallocate_dfaacc_union(array, size)
 
#define allocate_character_array(size)   (Char *) allocate_array( size, sizeof( Char ) )
 
#define reallocate_character_array(array, size)   (Char *) reallocate_array( (void *) array, size, sizeof( Char ) )
 

Typedefs

typedef struct hash_entryhash_table[]
 

Functions

void * allocate_array (int size, int element_size)
 
void * reallocate_array (void *array, int size, int element_size)
 
void ccladd (int, int)
 
int cclinit (void)
 
void cclnegate (int)
 
void list_character_set (FILE *, int[])
 
void increase_max_dfas (void)
 
void ntod (void)
 
void ccl2ecl (void)
 
int cre8ecs (int[], int[], int)
 
int ecs_from_xlation (int[])
 
void mkeccl (Char[], int, int[], int[], int, int)
 
void mkechar (int, int[], int[])
 
void make_tables (void)
 
void flexend (int) NORETURN
 
void action_out (void)
 
int all_lower (Char *)
 
int all_upper (Char *)
 
void bubble (int[], int)
 
void cshell (Char[], int, int)
 
void dataend (void)
 
void flexerror (char[]) NORETURN
 
void flexfatal (char[])
 
void lerrif (char[], int)
 
void lerrsf (char[], char[])
 
void line_directive_out (FILE *)
 
void mk2data (int)
 
void mkdata (int)
 
int myctoi (Char[])
 
void skelout (void)
 
void transition_struct_out (int, int)
 
void add_accept (int, int)
 
int copysingl (int, int)
 
void dumpnfa (int)
 
void finish_rule (int, int, int, int)
 
int link_machines (int, int)
 
void mark_beginning_as_normal (int)
 
int mkbranch (int, int)
 
int mkclos (int)
 
int mkopt (int)
 
int mkor (int, int)
 
int mkposcl (int)
 
int mkrep (int, int, int)
 
int mkstate (int)
 
void new_rule (void)
 
void format_pinpoint_message (char[], char[])
 
void pinpoint_message (char[])
 
void synerr (char[])
 
int flexscan ()
 
void set_input_file (char *)
 
int yywrap ()
 
void cclinstal (Char[], int)
 
int ccllookup (Char[])
 
void ndinstal (char[], Char[])
 
void scinstal (char[], int)
 
int sclookup (char[])
 
void bldtbl (int[], int, int, int, int)
 
void cmptmps (void)
 
void inittbl (void)
 
void mkdeftbl (void)
 
void mk1tbl (int, int, int, int)
 
void place_state (int *, int, int)
 
void stack1 (int, int, int, int)
 
int yylex ()
 

Variables

struct hash_entryndtbl [NAME_TABLE_HASH_SIZE]
 
struct hash_entrysctbl [START_COND_HASH_SIZE]
 
struct hash_entryccltab [CCL_HASH_SIZE]
 
int printstats
 
int syntaxerror
 
int eofseen
 
int ddebug
 
int trace
 
int spprdflt
 
int interactive
 
int caseins
 
int useecs
 
int fulltbl
 
int usemecs
 
int fullspd
 
int gen_line_dirs
 
int performance_report
 
int backtrack_report
 
int csize
 
int yymore_used
 
int reject
 
int real_reject
 
int continued_action
 
int yymore_really_used
 
int reject_really_used
 
int datapos
 
int dataline
 
int linenum
 
FILE * skelfile
 
FILE * yyin = (FILE *) 0
 
FILE * temp_action_file
 
FILE * backtrack_file
 
char * infilename
 
char ** input_files
 
int num_input_files
 
char * program_name
 
int onestate [ONE_STACK_SIZE]
 
int onesym [ONE_STACK_SIZE]
 
int onenext [ONE_STACK_SIZE]
 
int onedef [ONE_STACK_SIZE]
 
int onesp
 
int current_mns
 
int num_rules
 
int current_max_rules
 
int lastnfa
 
int * firstst
 
int * lastst
 
int * finalst
 
int * transchar
 
int * trans1
 
int * trans2
 
int * accptnum
 
int * assoc_rule
 
int * state_type
 
int * rule_type
 
int * rule_linenum
 
int current_state_type
 
int variable_trailing_context_rules
 
int numtemps
 
int numprots
 
int protprev [MSP]
 
int protnext [MSP]
 
int prottbl [MSP]
 
int protcomst [MSP]
 
int firstprot
 
int lastprot
 
int protsave [PROT_SAVE_SIZE]
 
int numecs
 
int nextecm [CSIZE+1]
 
int ecgroup [CSIZE+1]
 
int nummecs
 
int tecfwd [CSIZE+1]
 
int tecbck [CSIZE+1]
 
int * xlation
 
int num_xlations
 
int lastsc
 
int current_max_scs
 
int * scset
 
int * scbol
 
int * scxclu
 
int * sceof
 
int * actvsc
 
char ** scname
 
int current_max_dfa_size
 
int current_max_xpairs
 
int current_max_template_xpairs
 
int current_max_dfas
 
int lastdfa
 
int lasttemp
 
int * nxt
 
int * chk
 
int * tnxt
 
int * base
 
int * def
 
int * nultrans
 
int NUL_ec
 
int tblend
 
int firstfree
 
int ** dss
 
int * dfasiz
 
union dfaacc_uniondfaacc
 
int * accsiz
 
int * dhash
 
int numas
 
int numsnpairs
 
int jambase
 
int jamstate
 
int end_of_buffer_state
 
int lastccl
 
int current_maxccls
 
int * cclmap
 
int * ccllen
 
int * cclng
 
int cclreuse
 
int current_max_ccl_tbl_size
 
Charccltbl
 
char * starttime
 
char * endtime
 
char nmstr [MAXLINE]
 
int sectnum
 
int nummt
 
int hshcol
 
int dfaeql
 
int numeps
 
int eps2
 
int num_reallocs
 
int tmpuses
 
int totnst
 
int peakpairs
 
int numuniq
 
int numdup
 
int hshsave
 
int num_backtracking
 
int bol_needed
 

Macro Definition Documentation

#define ACCEPTABLE_DIFF_PERCENTAGE   50

Definition at line 227 of file flexdef.h.

#define ACTION_POSITION   -2

Definition at line 96 of file flexdef.h.

#define allocate_char_ptr_array (   size)    (char **) allocate_array( size, sizeof( char * ) )

Definition at line 590 of file flexdef.h.

#define allocate_character_array (   size)    (Char *) allocate_array( size, sizeof( Char ) )

Definition at line 607 of file flexdef.h.

#define allocate_dfaacc_union (   size)
Value:
(union dfaacc_union *) \
allocate_array( size, sizeof( union dfaacc_union ) )
void * allocate_array(int size, int element_size)
Definition: misc.c:76

Definition at line 593 of file flexdef.h.

#define allocate_int_ptr_array (   size)    (int **) allocate_array( size, sizeof( int * ) )

Definition at line 587 of file flexdef.h.

#define allocate_integer_array (   size)    (int *) allocate_array( size, sizeof( int ) )

Definition at line 581 of file flexdef.h.

#define BAD_SUBSCRIPT   -32767

Definition at line 268 of file flexdef.h.

#define CCL_HASH_SIZE   101

Definition at line 296 of file flexdef.h.

#define Char   unsigned char

Definition at line 59 of file flexdef.h.

#define CHECK_COM_PERCENTAGE   50

Definition at line 214 of file flexdef.h.

#define CSIZE   256

Definition at line 58 of file flexdef.h.

#define DEFAULT_CSIZE   128

Definition at line 67 of file flexdef.h.

#define DEFAULT_SKELETON_FILE   "flex.skel"

Definition at line 89 of file flexdef.h.

#define EOB_POSITION   -1

Definition at line 95 of file flexdef.h.

#define false   0

Definition at line 85 of file flexdef.h.

#define FILENAMESIZE   1024

Definition at line 75 of file flexdef.h.

#define FIRST_MATCH_DIFF_PERCENTAGE   10

Definition at line 221 of file flexdef.h.

#define FLEX_8_BIT_CHARS

Definition at line 55 of file flexdef.h.

#define FREE_EPSILON (   state)
Value:
(transchar[state] == SYM_EPSILON && \
trans2[state] == NO_TRANSITION && \
finalst[state] != state)
#define SYM_EPSILON
Definition: flexdef.h:192
int * finalst
Definition: flex.c:77
#define NO_TRANSITION
Definition: flexdef.h:156
int * transchar
Definition: flex.c:77
int * trans2
Definition: flex.c:77

Definition at line 112 of file flexdef.h.

#define INFINITY   -1 /* for x{5,} constructions */

Definition at line 158 of file flexdef.h.

#define INITIAL_MAX_CCL_TBL_SIZE   500

Definition at line 164 of file flexdef.h.

#define INITIAL_MAX_CCLS   100 /* max number of unique character classes */

Definition at line 160 of file flexdef.h.

#define INITIAL_MAX_DFA_SIZE   750

Definition at line 128 of file flexdef.h.

#define INITIAL_MAX_DFAS   1000 /* default maximum number of dfa states */

Definition at line 173 of file flexdef.h.

#define INITIAL_MAX_RULES   100 /* default maximum number of rules */

Definition at line 167 of file flexdef.h.

#define INITIAL_MAX_SCS   40 /* maximum number of start conditions */

Definition at line 194 of file flexdef.h.

#define INITIAL_MAX_TEMPLATE_XPAIRS   2500

Definition at line 189 of file flexdef.h.

#define INITIAL_MAX_XPAIRS   2000

Definition at line 185 of file flexdef.h.

#define INITIAL_MNS   2000 /* default maximum number of nfa states */

Definition at line 170 of file flexdef.h.

#define INTERIOR_FIT_PERCENTAGE   15

Definition at line 245 of file flexdef.h.

#define JAM   -1 /* to mark a missing DFA transition */

Definition at line 155 of file flexdef.h.

#define JAMSTATE   -32766 /* marks a reference to the state that always jams */

Definition at line 176 of file flexdef.h.

#define MARKER_DIFFERENCE   32000

Definition at line 181 of file flexdef.h.

#define max (   x,
 
)    ((x) > (y) ? (x) : (y))

Definition at line 81 of file flexdef.h.

#define MAX_ASSOC_RULES   100

Definition at line 263 of file flexdef.h.

#define MAX_CCL_TBL_SIZE_INCREMENT   250

Definition at line 165 of file flexdef.h.

#define MAX_CCLS_INCREMENT   100

Definition at line 161 of file flexdef.h.

#define MAX_DFA_SIZE_INCREMENT   750

Definition at line 129 of file flexdef.h.

#define MAX_DFAS_INCREMENT   1000

Definition at line 174 of file flexdef.h.

#define MAX_RULE   (YY_TRAILING_MASK - 1)

Definition at line 147 of file flexdef.h.

#define MAX_RULES_INCREMENT   100

Definition at line 168 of file flexdef.h.

#define MAX_SCS_INCREMENT   40 /* amount to bump by if it's not enough */

Definition at line 195 of file flexdef.h.

#define MAX_SHORT   32766

Definition at line 273 of file flexdef.h.

#define MAX_TEMPLATE_XPAIRS_INCREMENT   2500

Definition at line 190 of file flexdef.h.

#define MAX_XPAIRS_INCREMENT   2000

Definition at line 186 of file flexdef.h.

#define MAX_XTIONS_FULL_INTERIOR_FIT   4

Definition at line 258 of file flexdef.h.

#define MAXIMUM_MNS   31999

Definition at line 182 of file flexdef.h.

#define MAXLINE   BUFSIZ

Definition at line 72 of file flexdef.h.

#define min (   x,
 
)    ((x) < (y) ? (x) : (y))

Definition at line 78 of file flexdef.h.

#define MNS_INCREMENT   1000 /* amount to bump above by if it's not enough */

Definition at line 171 of file flexdef.h.

#define MSP   50 /* maximum number of saved protos (protos on the proto queue) */

Definition at line 252 of file flexdef.h.

#define NAME_TABLE_HASH_SIZE   101

Definition at line 294 of file flexdef.h.

#define NEW_PROTO_DIFF_PERCENTAGE   20

Definition at line 239 of file flexdef.h.

#define NIL   0

Definition at line 153 of file flexdef.h.

#define NO_TRANSITION   NIL

Definition at line 156 of file flexdef.h.

#define NORETURN

Definition at line 51 of file flexdef.h.

#define NUMDATAITEMS   10

Definition at line 99 of file flexdef.h.

#define NUMDATALINES   10

Definition at line 104 of file flexdef.h.

#define ONE_STACK_SIZE   500 /* stack of states with only one out-transition */

Definition at line 197 of file flexdef.h.

#define PROT_SAVE_SIZE   2000

Definition at line 250 of file flexdef.h.

#define PROTO_SIZE_PERCENTAGE   15

Definition at line 206 of file flexdef.h.

#define reallocate_char_ptr_array (   array,
  size 
)    (char **) reallocate_array( (void *) array, size, sizeof( char * ) )

Definition at line 600 of file flexdef.h.

#define reallocate_character_array (   array,
  size 
)    (Char *) reallocate_array( (void *) array, size, sizeof( Char ) )

Definition at line 610 of file flexdef.h.

#define reallocate_dfaacc_union (   array,
  size 
)
Value:
(union dfaacc_union *) \
reallocate_array( (void *) array, size, sizeof( union dfaacc_union ) )
void * reallocate_array(void *array, int size, int element_size)
Definition: misc.c:707

Definition at line 603 of file flexdef.h.

#define reallocate_int_ptr_array (   array,
  size 
)    (int **) reallocate_array( (void *) array, size, sizeof( int * ) )

Definition at line 597 of file flexdef.h.

#define reallocate_integer_array (   array,
  size 
)    (int *) reallocate_array( (void *) array, size, sizeof( int ) )

Definition at line 584 of file flexdef.h.

#define REALLY_NOT_DETERMINED   0

Definition at line 339 of file flexdef.h.

#define REALLY_NOT_USED   2

Definition at line 341 of file flexdef.h.

#define REALLY_USED   1

Definition at line 340 of file flexdef.h.

#define RULE_NORMAL   0

Definition at line 421 of file flexdef.h.

#define RULE_VARIABLE   1

Definition at line 422 of file flexdef.h.

#define SAME_TRANS   -1 /* transition is the same as "default" entry for state */

Definition at line 198 of file flexdef.h.

#define START_COND_HASH_SIZE   101

Definition at line 295 of file flexdef.h.

#define STATE_NORMAL   0x1

Definition at line 413 of file flexdef.h.

#define STATE_TRAILING_CONTEXT   0x2

Definition at line 414 of file flexdef.h.

#define SUPER_FREE_EPSILON (   state)
Value:
(transchar[state] == SYM_EPSILON && \
trans1[state] == NO_TRANSITION) \
#define SYM_EPSILON
Definition: flexdef.h:192
int * trans1
Definition: flex.c:77
#define NO_TRANSITION
Definition: flexdef.h:156
int * transchar
Definition: flex.c:77

Definition at line 120 of file flexdef.h.

#define SYM_EPSILON   (CSIZE + 1) /* to mark transitions on the symbol epsilon */

Definition at line 192 of file flexdef.h.

#define TEMPLATE_SAME_PERCENTAGE   60

Definition at line 233 of file flexdef.h.

#define TRANS_STRUCT_PRINT_LENGTH   15

Definition at line 107 of file flexdef.h.

#define true   1

Definition at line 84 of file flexdef.h.

#define UNIQUE   -1 /* marks a symbol as an e.c. representative */

Definition at line 157 of file flexdef.h.

#define YY_TRAILING_HEAD_MASK   0x4000

Definition at line 144 of file flexdef.h.

#define YY_TRAILING_MASK   0x2000

Definition at line 141 of file flexdef.h.

Typedef Documentation

typedef struct hash_entry* hash_table[]

Definition at line 292 of file flexdef.h.

Function Documentation

void action_out ( void  )

Definition at line 62 of file misc.c.

63 {
64  char buf[MAXLINE];
65 
66  while ( fgets( buf, MAXLINE, temp_action_file ) != NULL )
67  if ( buf[0] == '%' && buf[1] == '%' )
68  break;
69  else
70  fputs( buf, stdout );
71  }
#define NULL
Definition: catime.c:38
#define stdout
Definition: epicsStdio.h:30
#define MAXLINE
Definition: flexdef.h:72
FILE * temp_action_file
Definition: flex.c:103
void add_accept ( int  ,
int   
)

Definition at line 55 of file nfa.c.

56 {
57  /* hang the accepting number off an epsilon state. if it is associated
58  * with a state that has a non-epsilon out-transition, then the state
59  * will accept BEFORE it makes that transition, i.e., one character
60  * too soon
61  */
62 
63  if ( transchar[finalst[mach]] == SYM_EPSILON )
64  accptnum[finalst[mach]] = accepting_number;
65 
66  else
67  {
68  int astate = mkstate( SYM_EPSILON );
69  accptnum[astate] = accepting_number;
70  mach = link_machines( mach, astate );
71  }
72  }
#define SYM_EPSILON
Definition: flexdef.h:192
int * finalst
Definition: flex.c:77
int * accptnum
Definition: flex.c:78
int mkstate(int sym)
Definition: nfa.c:578
int link_machines(int first, int last)
Definition: nfa.c:283
int * transchar
Definition: flex.c:77
int all_lower ( Char )

Definition at line 104 of file misc.c.

105 {
106  while ( *str )
107  {
108  if ( ! isascii( (int) *str ) || ! islower( (int) *str ) )
109  return ( 0 );
110  ++str;
111  }
112 
113  return ( 1 );
114  }
#define str(v)
#define isascii(c)
Definition: misc.c:43
int all_upper ( Char )

Definition at line 125 of file misc.c.

126 {
127  while ( *str )
128  {
129  if ( ! isascii( (int) *str ) || ! isupper( (int) *str ) )
130  return ( 0 );
131  ++str;
132  }
133 
134  return ( 1 );
135  }
#define str(v)
#define isascii(c)
Definition: misc.c:43
void* allocate_array ( int  size,
int  element_size 
)

Definition at line 76 of file misc.c.

77 {
78  void *mem;
79 
80  /* on 16-bit int machines (e.g., 80286) we might be trying to
81  * allocate more than a signed int can hold, and that won't
82  * work. Cheap test:
83  */
84  if ( element_size * size <= 0 )
85  flexfatal( "request for < 1 byte in allocate_array()" );
86 
87  mem = (void *) malloc( (unsigned) (element_size * size) );
88 
89  if ( mem == NULL )
90  flexfatal( "memory allocation failed in allocate_array()" );
91 
92  return ( mem );
93  }
#define NULL
Definition: catime.c:38
void flexfatal(char *msg)
Definition: misc.c:352
void bldtbl ( int  [],
int  ,
int  ,
int  ,
int   
)
void bubble ( int  [],
int   
)

Definition at line 152 of file misc.c.

153 {
154  int i, j, k;
155 
156  for ( i = n; i > 1; --i )
157  for ( j = 1; j < i; ++j )
158  if ( v[j] > v[j + 1] ) /* compare */
159  {
160  k = v[j]; /* exchange */
161  v[j] = v[j + 1];
162  v[j + 1] = k;
163  }
164  }
int i
Definition: scan.c:967
void ccl2ecl ( void  )

Definition at line 45 of file ecs.c.

46 {
47  int i, ich, newlen, cclp, ccls, cclmec;
48 
49  for ( i = 1; i <= lastccl; ++i )
50  {
51  /* we loop through each character class, and for each character
52  * in the class, add the character's equivalence class to the
53  * new "character" class we are creating. Thus when we are all
54  * done, character classes will really consist of collections
55  * of equivalence classes
56  */
57 
58  newlen = 0;
59  cclp = cclmap[i];
60 
61  for ( ccls = 0; ccls < ccllen[i]; ++ccls )
62  {
63  ich = ccltbl[cclp + ccls];
64  cclmec = ecgroup[ich];
65 
66  if ( xlation && cclmec < 0 )
67  {
68  /* special hack--if we're doing %t tables then it's
69  * possible that no representative of this character's
70  * equivalence class is in the ccl. So waiting till
71  * we see the representative would be disastrous. Instead,
72  * we add this character's equivalence class anyway, if it's
73  * not already present.
74  */
75  int j;
76 
77  /* this loop makes this whole process n^2; but we don't
78  * really care about %t performance anyway
79  */
80  for ( j = 0; j < newlen; ++j )
81  if ( ccltbl[cclp + j] == -cclmec )
82  break;
83 
84  if ( j >= newlen )
85  { /* no representative yet, add this one in */
86  ccltbl[cclp + newlen] = -cclmec;
87  ++newlen;
88  }
89  }
90 
91  else if ( cclmec > 0 )
92  {
93  ccltbl[cclp + newlen] = cclmec;
94  ++newlen;
95  }
96  }
97 
98  ccllen[i] = newlen;
99  }
100  }
int ecgroup[CSIZE+1]
Definition: flex.c:83
int i
Definition: scan.c:967
int * xlation
Definition: flex.c:85
int * ccllen
Definition: flex.c:96
int * cclmap
Definition: flex.c:96
Char * ccltbl
Definition: flex.c:98
int lastccl
Definition: flex.c:96
void ccladd ( int  ,
int   
)

Definition at line 47 of file ccl.c.

48 {
49  int ind, len, newpos, i;
50 
51  len = ccllen[cclp];
52  ind = cclmap[cclp];
53 
54  /* check to see if the character is already in the ccl */
55 
56  for ( i = 0; i < len; ++i )
57  if ( ccltbl[ind + i] == ch )
58  return;
59 
60  newpos = ind + len;
61 
62  if ( newpos >= current_max_ccl_tbl_size )
63  {
65 
66  ++num_reallocs;
67 
69  }
70 
71  ccllen[cclp] = len + 1;
72  ccltbl[newpos] = ch;
73  }
int i
Definition: scan.c:967
int num_reallocs
Definition: flex.c:100
int * ccllen
Definition: flex.c:96
int * cclmap
Definition: flex.c:96
#define reallocate_character_array(array, size)
Definition: flexdef.h:610
Char * ccltbl
Definition: flex.c:98
#define MAX_CCL_TBL_SIZE_INCREMENT
Definition: flexdef.h:165
int current_max_ccl_tbl_size
Definition: flex.c:97
int cclinit ( void  )

Definition at line 83 of file ccl.c.

84 {
85  if ( ++lastccl >= current_maxccls )
86  {
88 
89  ++num_reallocs;
90 
94  }
95 
96  if ( lastccl == 1 )
97  /* we're making the first ccl */
98  cclmap[lastccl] = 0;
99 
100  else
101  /* the new pointer is just past the end of the last ccl. Since
102  * the cclmap points to the \first/ character of a ccl, adding the
103  * length of the ccl to the cclmap pointer will produce a cursor
104  * to the first free space
105  */
106  cclmap[lastccl] = cclmap[lastccl - 1] + ccllen[lastccl - 1];
107 
108  ccllen[lastccl] = 0;
109  cclng[lastccl] = 0; /* ccl's start out life un-negated */
110 
111  return ( lastccl );
112  }
#define MAX_CCLS_INCREMENT
Definition: flexdef.h:161
int num_reallocs
Definition: flex.c:100
int current_maxccls
Definition: flex.c:96
int * cclng
Definition: flex.c:96
#define reallocate_integer_array(array, size)
Definition: flexdef.h:584
int * ccllen
Definition: flex.c:96
int * cclmap
Definition: flex.c:96
int lastccl
Definition: flex.c:96
void cclinstal ( Char  [],
int   
)
int ccllookup ( Char  [])
void cclnegate ( int  )

Definition at line 122 of file ccl.c.

123 {
124  cclng[cclp] = 1;
125  }
int * cclng
Definition: flex.c:96
void cmptmps ( void  )

Definition at line 228 of file tblcmp.c.

229 {
230  int tmpstorage[CSIZE + 1];
231  int *tmp = tmpstorage, i, j;
232  int totaltrans, trans;
233 
235 
236  if ( usemecs )
237  {
238  /* create equivalence classes base on data gathered on template
239  * transitions
240  */
241 
243  }
244 
245  else
246  nummecs = numecs;
247 
248  if ( lastdfa + numtemps + 1 >= current_max_dfas )
250 
251  /* loop through each template */
252 
253  for ( i = 1; i <= numtemps; ++i )
254  {
255  totaltrans = 0; /* number of non-jam transitions out of this template */
256 
257  for ( j = 1; j <= numecs; ++j )
258  {
259  trans = tnxt[numecs * i + j];
260 
261  if ( usemecs )
262  {
263  /* the absolute value of tecbck is the meta-equivalence class
264  * of a given equivalence class, as set up by cre8ecs
265  */
266  if ( tecbck[j] > 0 )
267  {
268  tmp[tecbck[j]] = trans;
269 
270  if ( trans > 0 )
271  ++totaltrans;
272  }
273  }
274 
275  else
276  {
277  tmp[j] = trans;
278 
279  if ( trans > 0 )
280  ++totaltrans;
281  }
282  }
283 
284  /* it is assumed (in a rather subtle way) in the skeleton that
285  * if we're using meta-equivalence classes, the def[] entry for
286  * all templates is the jam template, i.e., templates never default
287  * to other non-jam table entries (e.g., another template)
288  */
289 
290  /* leave room for the jam-state after the last real state */
291  mkentry( tmp, nummecs, lastdfa + i + 1, JAMSTATE, totaltrans );
292  }
293  }
int nummecs
Definition: flex.c:83
int tecbck[CSIZE+1]
Definition: flex.c:84
int cre8ecs(int fwd[], int bck[], int num)
Definition: ecs.c:115
int i
Definition: scan.c:967
int tblend
Definition: flex.c:92
int peakpairs
Definition: flex.c:101
int lastdfa
Definition: flex.c:91
int numtemps
Definition: flex.c:81
int usemecs
Definition: flex.c:67
int * tnxt
Definition: flex.c:91
int current_max_dfas
Definition: flex.c:90
void increase_max_dfas(void)
Definition: dfa.c:370
#define JAMSTATE
Definition: flexdef.h:176
int numecs
Definition: flex.c:83
#define CSIZE
Definition: flexdef.h:58
void mkentry(int *, int, int, int, int)
Definition: tblcmp.c:517
int tecfwd[CSIZE+1]
Definition: flex.c:83
int copysingl ( int  ,
int   
)

Definition at line 86 of file nfa.c.

87 {
88  int copy, i;
89 
90  copy = mkstate( SYM_EPSILON );
91 
92  for ( i = 1; i <= num; ++i )
93  copy = link_machines( copy, dupmachine( singl ) );
94 
95  return ( copy );
96  }
int i
Definition: scan.c:967
#define SYM_EPSILON
Definition: flexdef.h:192
void copy(PVValueArray< T > &pvFrom, size_t fromOffset, size_t fromStride, PVValueArray< T > &pvTo, size_t toOffset, size_t toStride, size_t count)
Copy a subarray from one scalar array to another.
int dupmachine(int)
Definition: nfa.c:158
int mkstate(int sym)
Definition: nfa.c:578
int link_machines(int first, int last)
Definition: nfa.c:283
int cre8ecs ( int  [],
int  [],
int   
)

Definition at line 115 of file ecs.c.

116 {
117  int i, j, numcl;
118 
119  numcl = 0;
120 
121  /* create equivalence class numbers. From now on, abs( bck(x) )
122  * is the equivalence class number for object x. If bck(x)
123  * is positive, then x is the representative of its equivalence
124  * class.
125  */
126  for ( i = 1; i <= num; ++i )
127  if ( bck[i] == NIL )
128  {
129  bck[i] = ++numcl;
130  for ( j = fwd[i]; j != NIL; j = fwd[j] )
131  bck[j] = -numcl;
132  }
133 
134  return ( numcl );
135  }
int i
Definition: scan.c:967
#define NIL
Definition: flexdef.h:153
void cshell ( Char  [],
int  ,
int   
)
void dataend ( void  )

Definition at line 292 of file misc.c.

293 {
294  if ( datapos > 0 )
295  dataflush();
296 
297  /* add terminator for initialization */
298  puts( " } ;\n" );
299 
300  dataline = 0;
301  datapos = 0;
302  }
#define puts
Definition: epicsStdio.h:46
int datapos
Definition: flex.c:71
void dataflush(void)
Definition: misc.c:312
int dataline
Definition: flex.c:71
void dumpnfa ( int  )

Definition at line 106 of file nfa.c.

107 {
108  int sym, tsp1, tsp2, anum, ns;
109 
110  fprintf( stderr, "\n\n********** beginning dump of nfa with start state %d\n",
111  state1 );
112 
113  /* we probably should loop starting at firstst[state1] and going to
114  * lastst[state1], but they're not maintained properly when we "or"
115  * all of the rules together. So we use our knowledge that the machine
116  * starts at state 1 and ends at lastnfa.
117  */
118 
119  /* for ( ns = firstst[state1]; ns <= lastst[state1]; ++ns ) */
120  for ( ns = 1; ns <= lastnfa; ++ns )
121  {
122  fprintf( stderr, "state # %4d\t", ns );
123 
124  sym = transchar[ns];
125  tsp1 = trans1[ns];
126  tsp2 = trans2[ns];
127  anum = accptnum[ns];
128 
129  fprintf( stderr, "%3d: %4d, %4d", sym, tsp1, tsp2 );
130 
131  if ( anum != NIL )
132  fprintf( stderr, " [%d]", anum );
133 
134  fprintf( stderr, "\n" );
135  }
136 
137  fprintf( stderr, "********** end of dump\n" );
138  }
#define NIL
Definition: flexdef.h:153
int * accptnum
Definition: flex.c:78
int * trans2
Definition: flex.c:77
int * trans1
Definition: flex.c:77
int lastnfa
Definition: flex.c:76
#define stderr
Definition: epicsStdio.h:32
int * transchar
Definition: flex.c:77
int ecs_from_xlation ( int  [])

Definition at line 150 of file ecs.c.

151 {
152  int i;
153  int nul_is_alone = false;
154  int did_default_xlation_class = false;
155 
156  if ( xlation[0] != 0 )
157  {
158  /* if NUL shares its translation with other characters, choose one
159  * of the other characters as the representative for the equivalence
160  * class. This allows a cheap test later to see whether we can
161  * do away with NUL's equivalence class.
162  */
163  for ( i = 1; i < csize; ++i )
164  if ( xlation[i] == -xlation[0] )
165  {
166  xlation[i] = xlation[0];
167  ecmap[0] = -xlation[0];
168  break;
169  }
170 
171  if ( i >= csize )
172  /* didn't find a companion character--remember this fact */
173  nul_is_alone = true;
174  }
175 
176  for ( i = 1; i < csize; ++i )
177  if ( xlation[i] == 0 )
178  {
179  if ( did_default_xlation_class )
180  ecmap[i] = -num_xlations;
181 
182  else
183  {
184  /* make an equivalence class for those characters not
185  * specified in the %t table
186  */
187  ++num_xlations;
188  ecmap[i] = num_xlations;
189  did_default_xlation_class = true;
190  }
191  }
192 
193  else
194  ecmap[i] = xlation[i];
195 
196  if ( nul_is_alone )
197  /* force NUL's equivalence class to be the last one */
198  {
199  ++num_xlations;
200  ecmap[0] = num_xlations;
201 
202  /* there's actually a bug here: if someone is fanatic enough to
203  * put every character in its own translation class, then right
204  * now we just promoted NUL's equivalence class to be csize + 1;
205  * we can handle NUL's class number being == csize (by instead
206  * putting it in its own table), but we can't handle some *other*
207  * character having to be put in its own table, too. So in
208  * this case we bail out.
209  */
210  if ( num_xlations > csize )
211  flexfatal( "too many %t classes!" );
212  }
213 
214  return num_xlations;
215  }
int i
Definition: scan.c:967
int * xlation
Definition: flex.c:85
int csize
Definition: flex.c:68
void flexfatal(char[])
int num_xlations
Definition: flex.c:86
void finish_rule ( int  ,
int  ,
int  ,
int   
)

Definition at line 209 of file nfa.c.

210 {
211  add_accept( mach, num_rules );
212 
213  /* we did this in new_rule(), but it often gets the wrong
214  * number because we do it before we start parsing the current rule
215  */
217 
218  /* if this is a continued action, then the line-number has
219  * already been updated, giving us the wrong number
220  */
221  if ( continued_action )
223 
224  fprintf( temp_action_file, "case %d:\n", num_rules );
225 
226  if ( variable_trail_rule )
227  {
229 
230  if ( performance_report )
231  fprintf( stderr, "Variable trailing context rule at line %d\n",
233 
235  }
236 
237  else
238  {
240 
241  if ( headcnt > 0 || trailcnt > 0 )
242  {
243  /* do trailing context magic to not match the trailing characters */
244  char *scanner_cp = "yy_c_buf_p = yy_cp";
245  char *scanner_bp = "yy_bp";
246 
247  fprintf( temp_action_file,
248  "*yy_cp = yy_hold_char; /* undo effects of setting up yytext */\n" );
249 
250  if ( headcnt > 0 )
251  fprintf( temp_action_file, "%s = %s + %d;\n",
252  scanner_cp, scanner_bp, headcnt );
253 
254  else
255  fprintf( temp_action_file,
256  "%s -= %d;\n", scanner_cp, trailcnt );
257 
258  fprintf( temp_action_file,
259  "YY_DO_BEFORE_ACTION; /* set up yytext again */\n" );
260  }
261  }
262 
264  }
#define RULE_VARIABLE
Definition: flexdef.h:422
int continued_action
Definition: flex.c:69
int * rule_type
Definition: flex.c:78
int variable_trailing_context_rules
Definition: flex.c:80
int linenum
Definition: flex.c:71
int * rule_linenum
Definition: flex.c:78
int num_rules
Definition: flex.c:76
void add_accept(int mach, int accepting_number)
Definition: nfa.c:55
int performance_report
Definition: flex.c:68
void line_directive_out(FILE *)
Definition: misc.c:479
FILE * temp_action_file
Definition: flex.c:103
#define stderr
Definition: epicsStdio.h:32
#define RULE_NORMAL
Definition: flexdef.h:421
void flexend ( int  )

Definition at line 196 of file flex.c.

197 {
198  int tblsiz;
199  char *flex_gettime();
200 
201  if ( skelfile != NULL )
202  {
203  if ( ferror( skelfile ) )
204  flexfatal( "error occurred when writing skeleton file" );
205 
206  else if ( fclose( skelfile ) )
207  flexfatal( "error occurred when closing skeleton file" );
208  }
209 
210  if ( temp_action_file )
211  {
212  if ( ferror( temp_action_file ) )
213  flexfatal( "error occurred when writing temporary action file" );
214 
215  else if ( fclose( temp_action_file ) )
216  flexfatal( "error occurred when closing temporary action file" );
217  }
218 
219  if ( status != 0 && outfile_created )
220  {
221  if ( ferror( stdout ) )
222  flexfatal( "error occurred when writing output file" );
223 
224  else if ( fclose( stdout ) )
225  flexfatal( "error occurred when closing output file" );
226 
227  else if ( unlink( outfile ) )
228  flexfatal( "error occurred when deleting output file" );
229  }
230 
232  {
233  if ( num_backtracking == 0 )
234  fprintf( backtrack_file, "No backtracking.\n" );
235  else if ( fullspd || fulltbl )
236  fprintf( backtrack_file,
237  "%d backtracking (non-accepting) states.\n",
239  else
240  fprintf( backtrack_file, "Compressed tables always backtrack.\n" );
241 
242  if ( ferror( backtrack_file ) )
243  flexfatal( "error occurred when writing backtracking file" );
244 
245  else if ( fclose( backtrack_file ) )
246  flexfatal( "error occurred when closing backtracking file" );
247  }
248 
249  if ( printstats )
250  {
251  endtime = flex_gettime();
252 
253  fprintf( stderr, "%s version %s usage statistics:\n", program_name,
254  flex_version );
255  fprintf( stderr, " started at %s, finished at %s\n",
256  starttime, endtime );
257 
258  fprintf( stderr, " scanner options: -" );
259 
260  if ( backtrack_report )
261  putc( 'b', stderr );
262  if ( ddebug )
263  putc( 'd', stderr );
264  if ( interactive )
265  putc( 'I', stderr );
266  if ( caseins )
267  putc( 'i', stderr );
268  if ( ! gen_line_dirs )
269  putc( 'L', stderr );
270  if ( performance_report )
271  putc( 'p', stderr );
272  if ( spprdflt )
273  putc( 's', stderr );
274  if ( use_stdout )
275  putc( 't', stderr );
276  if ( trace )
277  putc( 'T', stderr );
278  if ( printstats )
279  putc( 'v', stderr ); /* always true! */
280  if ( csize == 256 )
281  putc( '8', stderr );
282 
283  fprintf( stderr, " -C" );
284 
285  if ( fulltbl )
286  putc( 'f', stderr );
287  if ( fullspd )
288  putc( 'F', stderr );
289  if ( useecs )
290  putc( 'e', stderr );
291  if ( usemecs )
292  putc( 'm', stderr );
293 
294  if ( strcmp( skelname, ENQUOTE(DEFAULT_SKELETON_FILE) ) )
295  fprintf( stderr, " -S%s", skelname );
296 
297  putc( '\n', stderr );
298 
299  fprintf( stderr, " %d/%d NFA states\n", lastnfa, current_mns );
300  fprintf( stderr, " %d/%d DFA states (%d words)\n", lastdfa,
302  fprintf( stderr,
303  " %d rules\n", num_rules - 1 /* - 1 for def. rule */ );
304 
305  if ( num_backtracking == 0 )
306  fprintf( stderr, " No backtracking\n" );
307  else if ( fullspd || fulltbl )
308  fprintf( stderr, " %d backtracking (non-accepting) states\n",
310  else
311  fprintf( stderr, " compressed tables always backtrack\n" );
312 
313  if ( bol_needed )
314  fprintf( stderr, " Beginning-of-line patterns used\n" );
315 
316  fprintf( stderr, " %d/%d start conditions\n", lastsc,
317  current_max_scs );
318  fprintf( stderr, " %d epsilon states, %d double epsilon states\n",
319  numeps, eps2 );
320 
321  if ( lastccl == 0 )
322  fprintf( stderr, " no character classes\n" );
323  else
324  fprintf( stderr,
325  " %d/%d character classes needed %d/%d words of storage, %d reused\n",
329 
330  fprintf( stderr, " %d state/nextstate pairs created\n", numsnpairs );
331  fprintf( stderr, " %d/%d unique/duplicate transitions\n",
332  numuniq, numdup );
333 
334  if ( fulltbl )
335  {
336  tblsiz = lastdfa * numecs;
337  fprintf( stderr, " %d table entries\n", tblsiz );
338  }
339 
340  else
341  {
342  tblsiz = 2 * (lastdfa + numtemps) + 2 * tblend;
343 
344  fprintf( stderr, " %d/%d base-def entries created\n",
346  fprintf( stderr, " %d/%d (peak %d) nxt-chk entries created\n",
348  fprintf( stderr,
349  " %d/%d (peak %d) template nxt-chk entries created\n",
351  numtemps * numecs );
352  fprintf( stderr, " %d empty table entries\n", nummt );
353  fprintf( stderr, " %d protos created\n", numprots );
354  fprintf( stderr, " %d templates created, %d uses\n",
355  numtemps, tmpuses );
356  }
357 
358  if ( useecs )
359  {
360  tblsiz = tblsiz + csize;
361  fprintf( stderr, " %d/%d equivalence classes created\n",
362  numecs, csize );
363  }
364 
365  if ( usemecs )
366  {
367  tblsiz = tblsiz + numecs;
368  fprintf( stderr, " %d/%d meta-equivalence classes created\n",
369  nummecs, csize );
370  }
371 
372  fprintf( stderr, " %d (%d saved) hash collisions, %d DFAs equal\n",
373  hshcol, hshsave, dfaeql );
374  fprintf( stderr, " %d sets of reallocations needed\n", num_reallocs );
375  fprintf( stderr, " %d total table entries needed\n", tblsiz );
376  }
377 
378  exit( status );
379 }
int tmpuses
Definition: flex.c:101
int nummecs
Definition: flex.c:83
char * endtime
Definition: flex.c:99
pvd::Status status
int printstats
Definition: flex.c:66
int fullspd
Definition: flex.c:68
int numuniq
Definition: flex.c:101
int interactive
Definition: flex.c:67
int hshcol
Definition: flex.c:100
int tblend
Definition: flex.c:92
int nummt
Definition: flex.c:100
int ddebug
Definition: flex.c:66
int num_reallocs
Definition: flex.c:100
int current_maxccls
Definition: flex.c:96
int peakpairs
Definition: flex.c:101
int numsnpairs
Definition: flex.c:95
#define NULL
Definition: catime.c:38
int numeps
Definition: flex.c:100
char * starttime
Definition: flex.c:99
int csize
Definition: flex.c:68
FILE * backtrack_file
Definition: flex.c:104
char * flex_gettime(void)
Definition: misc.c:381
int caseins
Definition: flex.c:67
int dfaeql
Definition: flex.c:100
int num_rules
Definition: flex.c:76
int useecs
Definition: flex.c:67
int cclreuse
Definition: flex.c:96
int lastdfa
Definition: flex.c:91
int current_mns
Definition: flex.c:76
int numdup
Definition: flex.c:101
#define DEFAULT_SKELETON_FILE
Definition: flexdef.h:89
int numtemps
Definition: flex.c:81
int current_max_template_xpairs
Definition: flex.c:90
int usemecs
Definition: flex.c:67
int current_max_scs
Definition: flex.c:87
int performance_report
Definition: flex.c:68
int spprdflt
Definition: flex.c:66
int eps2
Definition: flex.c:100
#define stdout
Definition: epicsStdio.h:30
int gen_line_dirs
Definition: flex.c:68
int bol_needed
Definition: flex.c:102
int numprots
Definition: flex.c:81
char * program_name
Definition: flex.c:108
int hshsave
Definition: flex.c:101
void flexfatal(char[])
int trace
Definition: flex.c:66
int lastsc
Definition: flex.c:87
int * ccllen
Definition: flex.c:96
int * cclmap
Definition: flex.c:96
int current_max_dfas
Definition: flex.c:90
int lastnfa
Definition: flex.c:76
int num_backtracking
Definition: flex.c:102
FILE * temp_action_file
Definition: flex.c:103
int totnst
Definition: flex.c:101
FILE * skelfile
Definition: flex.c:72
#define stderr
Definition: epicsStdio.h:32
int numecs
Definition: flex.c:83
int fulltbl
Definition: flex.c:67
#define ENQUOTE(path)
Definition: flex.c:37
int backtrack_report
Definition: flex.c:68
int lastccl
Definition: flex.c:96
int current_max_ccl_tbl_size
Definition: flex.c:97
int current_max_xpairs
Definition: flex.c:89
void flexerror ( char  [])
void flexfatal ( char  [])
int flexscan ( )
void format_pinpoint_message ( char  [],
char  [] 
)
void increase_max_dfas ( void  )

Definition at line 370 of file dfa.c.

371 {
373 
374  ++num_reallocs;
375 
383 
384  if ( nultrans )
386  }
int ** dss
Definition: flex.c:92
#define MAX_DFAS_INCREMENT
Definition: flexdef.h:174
int num_reallocs
Definition: flex.c:100
union dfaacc_union * dfaacc
Definition: flex.c:93
int * accsiz
Definition: flex.c:94
int * dfasiz
Definition: flex.c:92
#define reallocate_int_ptr_array(array, size)
Definition: flexdef.h:597
#define reallocate_integer_array(array, size)
Definition: flexdef.h:584
int * nultrans
Definition: flex.c:92
int current_max_dfas
Definition: flex.c:90
int * base
Definition: flex.c:92
int * def
Definition: flex.c:92
#define reallocate_dfaacc_union(array, size)
Definition: flexdef.h:603
int * dhash
Definition: flex.c:94
void inittbl ( void  )

Definition at line 430 of file tblcmp.c.

431 {
432  int i;
433 
434  memset( (char *) chk, 0,
435  current_max_xpairs * sizeof( int ) / sizeof( char ) );
436 
437  tblend = 0;
438  firstfree = tblend + 1;
439  numtemps = 0;
440 
441  if ( usemecs )
442  {
443  /* set up doubly-linked meta-equivalence classes
444  * these are sets of equivalence classes which all have identical
445  * transitions out of TEMPLATES
446  */
447 
448  tecbck[1] = NIL;
449 
450  for ( i = 2; i <= numecs; ++i )
451  {
452  tecbck[i] = i - 1;
453  tecfwd[i - 1] = i;
454  }
455 
456  tecfwd[numecs] = NIL;
457  }
458  }
int tecbck[CSIZE+1]
Definition: flex.c:84
int i
Definition: scan.c:967
int tblend
Definition: flex.c:92
#define NIL
Definition: flexdef.h:153
int firstfree
Definition: flex.c:92
int numtemps
Definition: flex.c:81
int usemecs
Definition: flex.c:67
int numecs
Definition: flex.c:83
int * chk
Definition: flex.c:91
int current_max_xpairs
Definition: flex.c:89
int tecfwd[CSIZE+1]
Definition: flex.c:83
void lerrif ( char  [],
int   
)
void lerrsf ( char  [],
char  [] 
)
void line_directive_out ( FILE *  )

Definition at line 479 of file misc.c.

480 {
481  if ( infilename && gen_line_dirs )
482  fprintf( output_file_name, "# line %d \"%s\"\n", linenum, infilename );
483  }
char * infilename
Definition: flex.c:73
int gen_line_dirs
Definition: flex.c:68
char * output_file_name
Definition: antelope.c:39
int link_machines ( int  ,
int   
)

Definition at line 283 of file nfa.c.

284 {
285  if ( first == NIL )
286  return ( last );
287 
288  else if ( last == NIL )
289  return ( first );
290 
291  else
292  {
293  mkxtion( finalst[first], last );
294  finalst[first] = finalst[last];
295  lastst[first] = max( lastst[first], lastst[last] );
296  firstst[first] = min( firstst[first], firstst[last] );
297 
298  return ( first );
299  }
300  }
#define max(x, y)
Definition: flexdef.h:81
int * firstst
Definition: flex.c:77
#define min(x, y)
Definition: flexdef.h:78
#define NIL
Definition: flexdef.h:153
int * finalst
Definition: flex.c:77
void mkxtion(int, int)
Definition: nfa.c:648
int * lastst
Definition: flex.c:77
void list_character_set ( FILE *  ,
int  [] 
)

Definition at line 140 of file ccl.c.

141 {
142  int i;
143  char *readable_form();
144 
145  putc( '[', file );
146 
147  for ( i = 0; i < csize; ++i )
148  {
149  if ( cset[i] )
150  {
151  int start_char = i;
152 
153  putc( ' ', file );
154 
155  fputs( readable_form( i ), file );
156 
157  while ( ++i < csize && cset[i] )
158  ;
159 
160  if ( i - 1 > start_char )
161  /* this was a run */
162  fprintf( file, "-%s", readable_form( i - 1 ) );
163 
164  putc( ' ', file );
165  }
166  }
167 
168  putc( ']', file );
169  }
int i
Definition: scan.c:967
char * readable_form(int c)
Definition: misc.c:672
int csize
Definition: flex.c:68
void make_tables ( void  )

Definition at line 994 of file gen.c.

995 {
996  int i;
997  int did_eof_rule = false;
998 
999  skelout();
1000 
1001  /* first, take care of YY_DO_BEFORE_ACTION depending on yymore being used */
1002  set_indent( 2 );
1003 
1004  if ( yymore_used )
1005  {
1006  indent_puts( "yytext -= yy_more_len; \\" );
1007  indent_puts( "yyleng = yy_cp - yytext; \\" );
1008  }
1009 
1010  else
1011  indent_puts( "yyleng = yy_cp - yy_bp; \\" );
1012 
1013  set_indent( 0 );
1014 
1015  skelout();
1016 
1017 
1018  printf( "#define YY_END_OF_BUFFER %d\n", num_rules + 1 );
1019 
1020  if ( fullspd )
1021  { /* need to define the transet type as a size large
1022  * enough to hold the biggest offset
1023  */
1024  int total_table_size = tblend + numecs + 1;
1025  char *trans_offset_type =
1026  total_table_size > MAX_SHORT ? "long" : "short";
1027 
1028  set_indent( 0 );
1029  indent_puts( "struct yy_trans_info" );
1030  indent_up();
1031  indent_puts( "{" );
1032  indent_puts( "short yy_verify;" );
1033 
1034  /* in cases where its sister yy_verify *is* a "yes, there is a
1035  * transition", yy_nxt is the offset (in records) to the next state.
1036  * In most cases where there is no transition, the value of yy_nxt
1037  * is irrelevant. If yy_nxt is the -1th record of a state, though,
1038  * then yy_nxt is the action number for that state
1039  */
1040 
1041  indent_put2s( "%s yy_nxt;", trans_offset_type );
1042  indent_puts( "};" );
1043  indent_down();
1044 
1045  indent_puts( "typedef const struct yy_trans_info *yy_state_type;" );
1046  }
1047 
1048  else
1049  indent_puts( "typedef int yy_state_type;" );
1050 
1051  if ( fullspd )
1052  genctbl();
1053 
1054  else if ( fulltbl )
1055  genftbl();
1056 
1057  else
1058  gentabs();
1059 
1060  if ( num_backtracking > 0 )
1061  {
1062  indent_puts( "static yy_state_type yy_last_accepting_state;" );
1063  indent_puts( "static YY_CHAR *yy_last_accepting_cpos;\n" );
1064  }
1065 
1066  if ( nultrans )
1067  {
1068  printf( C_state_decl, "yy_NUL_trans", lastdfa + 1 );
1069 
1070  for ( i = 1; i <= lastdfa; ++i )
1071  {
1072  if ( fullspd )
1073  {
1074  if ( nultrans )
1075  printf( " &yy_transition[%d],\n", base[i] );
1076  else
1077  printf( " 0,\n" );
1078  }
1079 
1080  else
1081  mkdata( nultrans[i] );
1082  }
1083 
1084  dataend();
1085  }
1086 
1087  if ( ddebug )
1088  { /* spit out table mapping rules to line numbers */
1089  indent_puts( "extern int yy_flex_debug;" );
1090  indent_puts( "int yy_flex_debug = 1;\n" );
1091 
1092  printf( C_short_decl, "yy_rule_linenum", num_rules );
1093  for ( i = 1; i < num_rules; ++i )
1094  mkdata( rule_linenum[i] );
1095  dataend();
1096  }
1097 
1098  if ( reject )
1099  {
1100  /* declare state buffer variables */
1101  puts(
1102  "static yy_state_type yy_state_buf[YY_BUF_SIZE + 2], *yy_state_ptr;" );
1103  puts( "static YY_CHAR *yy_full_match;" );
1104  puts( "static int yy_lp;" );
1105 
1107  {
1108  puts( "static int yy_looking_for_trail_begin = 0;" );
1109  puts( "static int yy_full_lp;" );
1110  puts( "static int *yy_full_state;" );
1111  printf( "#define YY_TRAILING_MASK 0x%x\n", YY_TRAILING_MASK );
1112  printf( "#define YY_TRAILING_HEAD_MASK 0x%x\n",
1114  }
1115 
1116  puts( "#define REJECT \\" );
1117  puts( "{ \\" );
1118  puts(
1119  "*yy_cp = yy_hold_char; /* undo effects of setting up yytext */ \\" );
1120  puts(
1121  "yy_cp = yy_full_match; /* restore poss. backed-over text */ \\" );
1122 
1124  {
1125  puts( "yy_lp = yy_full_lp; /* restore orig. accepting pos. */ \\" );
1126  puts(
1127  "yy_state_ptr = yy_full_state; /* restore orig. state */ \\" );
1128  puts(
1129  "yy_current_state = *yy_state_ptr; /* restore curr. state */ \\" );
1130  }
1131 
1132  puts( "++yy_lp; \\" );
1133  puts( "goto find_rule; \\" );
1134  puts( "}" );
1135  }
1136 
1137  else
1138  {
1139  puts( "/* the intent behind this definition is that it'll catch" );
1140  puts( " * any uses of REJECT which flex missed" );
1141  puts( " */" );
1142  puts( "#define REJECT reject_used_but_not_detected" );
1143  }
1144 
1145  if ( yymore_used )
1146  {
1147  indent_puts( "static int yy_more_flag = 0;" );
1148  indent_puts( "static int yy_doing_yy_more = 0;" );
1149  indent_puts( "static int yy_more_len = 0;" );
1150  indent_puts(
1151  "#define yymore() { yy_more_flag = 1; }" );
1152  indent_puts(
1153  "#define YY_MORE_ADJ (yy_doing_yy_more ? yy_more_len : 0)" );
1154  }
1155 
1156  else
1157  {
1158  indent_puts( "#define yymore() yymore_used_but_not_detected" );
1159  indent_puts( "#define YY_MORE_ADJ 0" );
1160  }
1161 
1162  skelout();
1163 
1164  if ( ferror( temp_action_file ) )
1165  flexfatal( "error occurred when writing temporary action file" );
1166 
1167  else if ( fseek( temp_action_file, 0L, SEEK_SET) != 0 )
1168  flexfatal( "error occurred when rewinding temporary action file" );
1169 
1170  /* copy prolog from action_file to output file */
1171  action_out();
1172 
1173  skelout();
1174 
1175  set_indent( 2 );
1176 
1177  if ( yymore_used )
1178  {
1179  indent_puts( "yy_more_len = 0;" );
1180  indent_puts( "yy_doing_yy_more = yy_more_flag;" );
1181  indent_puts( "if ( yy_doing_yy_more )" );
1182  indent_up();
1183  indent_puts( "{" );
1184  indent_puts( "yy_more_len = yyleng;" );
1185  indent_puts( "yy_more_flag = 0;" );
1186  indent_puts( "}" );
1187  indent_down();
1188  }
1189 
1190  skelout();
1191 
1192  gen_start_state();
1193 
1194  /* note, don't use any indentation */
1195  puts( "yy_match:" );
1196  gen_next_match();
1197 
1198  skelout();
1199  set_indent( 2 );
1200  gen_find_action();
1201 
1202  skelout();
1203  if ( ddebug )
1204  {
1205  indent_puts( "if ( yy_flex_debug )" );
1206  indent_up();
1207 
1208  indent_puts( "{" );
1209  indent_puts( "if ( yy_act == 0 )" );
1210  indent_up();
1211  indent_puts( "fprintf( stderr, \"--scanner backtracking\\n\" );" );
1212  indent_down();
1213 
1214  do_indent();
1215  printf( "else if ( yy_act < %d )\n", num_rules );
1216  indent_up();
1217  indent_puts(
1218  "fprintf( stderr, \"--accepting rule at line %d (\\\"%s\\\")\\n\"," );
1219  indent_puts( " yy_rule_linenum[yy_act], yytext );" );
1220  indent_down();
1221 
1222  do_indent();
1223  printf( "else if ( yy_act == %d )\n", num_rules );
1224  indent_up();
1225  indent_puts(
1226  "fprintf( stderr, \"--accepting default rule (\\\"%s\\\")\\n\"," );
1227  indent_puts( " yytext );" );
1228  indent_down();
1229 
1230  do_indent();
1231  printf( "else if ( yy_act == %d )\n", num_rules + 1 );
1232  indent_up();
1233  indent_puts( "fprintf( stderr, \"--(end of buffer or a NUL)\\n\" );" );
1234  indent_down();
1235 
1236  do_indent();
1237  printf( "else\n" );
1238  indent_up();
1239  indent_puts( "fprintf( stderr, \"--EOF\\n\" );" );
1240  indent_down();
1241 
1242  indent_puts( "}" );
1243  indent_down();
1244  }
1245 
1246  /* copy actions from action_file to output file */
1247  skelout();
1248  indent_up();
1249  gen_bt_action();
1250  action_out();
1251 
1252  /* generate cases for any missing EOF rules */
1253  for ( i = 1; i <= lastsc; ++i )
1254  if ( ! sceof[i] )
1255  {
1256  do_indent();
1257  printf( "case YY_STATE_EOF(%s):\n", scname[i] );
1258  did_eof_rule = true;
1259  }
1260 
1261  if ( did_eof_rule )
1262  {
1263  indent_up();
1264  indent_puts( "yyterminate();" );
1265  indent_down();
1266  }
1267 
1268 
1269  /* generate code for handling NUL's, if needed */
1270 
1271  /* first, deal with backtracking and setting up yy_cp if the scanner
1272  * finds that it should JAM on the NUL
1273  */
1274  skelout();
1275  set_indent( 7 );
1276 
1277  if ( fullspd || fulltbl )
1278  indent_puts( "yy_cp = yy_c_buf_p;" );
1279 
1280  else
1281  { /* compressed table */
1282  if ( ! reject && ! interactive )
1283  {
1284  /* do the guaranteed-needed backtrack to figure out the match */
1285  indent_puts( "yy_cp = yy_last_accepting_cpos;" );
1286  indent_puts( "yy_current_state = yy_last_accepting_state;" );
1287  }
1288  }
1289 
1290 
1291  /* generate code for yy_get_previous_state() */
1292  set_indent( 1 );
1293  skelout();
1294 
1295  if ( bol_needed )
1296  indent_puts( "YY_CHAR *yy_bp = yytext;\n" );
1297 
1298  gen_start_state();
1299 
1300  set_indent( 2 );
1301  skelout();
1302  gen_next_state( true );
1303 
1304  set_indent( 1 );
1305  skelout();
1306  gen_NUL_trans();
1307 
1308  skelout();
1309 
1310  /* copy remainder of input to output */
1311 
1313  (void) flexscan(); /* copy remainder of input to output */
1314  }
void indent_put2s(char[], char[])
#define indent_up()
Definition: gen.c:50
void gen_find_action(void)
Definition: gen.c:271
char ** scname
Definition: flex.c:88
int i
Definition: scan.c:967
int fullspd
Definition: flex.c:68
int variable_trailing_context_rules
Definition: flex.c:80
#define YY_TRAILING_HEAD_MASK
Definition: flexdef.h:144
int interactive
Definition: flex.c:67
int tblend
Definition: flex.c:92
int ddebug
Definition: flex.c:66
#define printf
Definition: epicsStdio.h:41
void action_out(void)
Definition: misc.c:62
void skelout(void)
Definition: misc.c:734
int * rule_linenum
Definition: flex.c:78
void indent_puts(char[])
int num_rules
Definition: flex.c:76
#define YY_TRAILING_MASK
Definition: flexdef.h:141
int lastdfa
Definition: flex.c:91
void dataend(void)
Definition: misc.c:292
#define puts
Definition: epicsStdio.h:46
void gentabs(void)
Definition: gen.c:729
void genftbl(void)
Definition: gen.c:391
void gen_next_state(int)
Definition: gen.c:563
void mkdata(int)
Definition: misc.c:524
#define stdout
Definition: epicsStdio.h:30
#define MAX_SHORT
Definition: flexdef.h:273
int bol_needed
Definition: flex.c:102
void line_directive_out(FILE *)
Definition: misc.c:479
int flexscan()
int reject
Definition: flex.c:69
void flexfatal(char[])
int lastsc
Definition: flex.c:87
void gen_start_state(void)
Definition: gen.c:695
int * nultrans
Definition: flex.c:92
int * sceof
Definition: flex.c:87
int num_backtracking
Definition: flex.c:102
FILE * temp_action_file
Definition: flex.c:103
int * base
Definition: flex.c:92
void gen_bt_action(void)
Definition: gen.c:106
void gen_next_match(void)
Definition: gen.c:468
int yymore_used
Definition: flex.c:69
void do_indent(void)
Definition: gen.c:65
#define set_indent(indent_val)
Definition: gen.c:52
int numecs
Definition: flex.c:83
int fulltbl
Definition: flex.c:67
void gen_NUL_trans(void)
Definition: gen.c:620
void genctbl(void)
Definition: gen.c:139
#define indent_down()
Definition: gen.c:51
void mark_beginning_as_normal ( int  )

Definition at line 316 of file nfa.c.

317 {
318  switch ( state_type[mach] )
319  {
320  case STATE_NORMAL:
321  /* oh, we've already visited here */
322  return;
323 
325  state_type[mach] = STATE_NORMAL;
326 
327  if ( transchar[mach] == SYM_EPSILON )
328  {
329  if ( trans1[mach] != NO_TRANSITION )
331 
332  if ( trans2[mach] != NO_TRANSITION )
334  }
335  break;
336 
337  default:
338  flexerror( "bad state type in mark_beginning_as_normal()" );
339  break;
340  }
341  }
#define SYM_EPSILON
Definition: flexdef.h:192
#define STATE_TRAILING_CONTEXT
Definition: flexdef.h:414
void mark_beginning_as_normal(int mach)
Definition: nfa.c:316
void flexerror(char[]) NORETURN
int * state_type
Definition: flex.c:78
int * trans2
Definition: flex.c:77
int * trans1
Definition: flex.c:77
#define NO_TRANSITION
Definition: flexdef.h:156
#define STATE_NORMAL
Definition: flexdef.h:413
int * transchar
Definition: flex.c:77
void mk1tbl ( int  ,
int  ,
int  ,
int   
)

Definition at line 647 of file tblcmp.c.

648 {
649  if ( firstfree < sym )
650  firstfree = sym;
651 
652  while ( chk[firstfree] != 0 )
653  if ( ++firstfree >= current_max_xpairs )
654  expand_nxt_chk();
655 
656  base[state] = firstfree - sym;
657  def[state] = onedef;
658  chk[firstfree] = state;
659  nxt[firstfree] = onenxt;
660 
661  if ( firstfree > tblend )
662  {
663  tblend = firstfree++;
664 
665  if ( firstfree >= current_max_xpairs )
666  expand_nxt_chk();
667  }
668  }
int tblend
Definition: flex.c:92
int firstfree
Definition: flex.c:92
int onedef[ONE_STACK_SIZE]
Definition: flex.c:75
int * nxt
Definition: flex.c:91
int * base
Definition: flex.c:92
int * def
Definition: flex.c:92
int * chk
Definition: flex.c:91
int current_max_xpairs
Definition: flex.c:89
void expand_nxt_chk(void)
Definition: tblcmp.c:299
void mk2data ( int  )

Definition at line 494 of file misc.c.

495 {
496  if ( datapos >= NUMDATAITEMS )
497  {
498  putchar( ',' );
499  dataflush();
500  }
501 
502  if ( datapos == 0 )
503  /* indent */
504  fputs( " ", stdout );
505 
506  else
507  putchar( ',' );
508 
509  ++datapos;
510 
511  printf( "%5d", value );
512  }
Definition: link.h:174
#define printf
Definition: epicsStdio.h:41
#define putchar
Definition: epicsStdio.h:51
int datapos
Definition: flex.c:71
#define NUMDATAITEMS
Definition: flexdef.h:99
#define stdout
Definition: epicsStdio.h:30
void dataflush(void)
Definition: misc.c:312
int mkbranch ( int  ,
int   
)

Definition at line 358 of file nfa.c.

359 {
360  int eps;
361 
362  if ( first == NO_TRANSITION )
363  return ( second );
364 
365  else if ( second == NO_TRANSITION )
366  return ( first );
367 
368  eps = mkstate( SYM_EPSILON );
369 
370  mkxtion( eps, first );
371  mkxtion( eps, second );
372 
373  return ( eps );
374  }
#define SYM_EPSILON
Definition: flexdef.h:192
int mkstate(int sym)
Definition: nfa.c:578
void mkxtion(int, int)
Definition: nfa.c:648
#define NO_TRANSITION
Definition: flexdef.h:156
int mkclos ( int  )

Definition at line 385 of file nfa.c.

386 {
387  return ( mkopt( mkposcl( state ) ) );
388  }
int mkposcl(int state)
Definition: nfa.c:501
int mkopt(int mach)
Definition: nfa.c:405
void mkdata ( int  )

Definition at line 524 of file misc.c.

525 {
526  if ( datapos >= NUMDATAITEMS )
527  {
528  putchar( ',' );
529  dataflush();
530  }
531 
532  if ( datapos == 0 )
533  /* indent */
534  fputs( " ", stdout );
535 
536  else
537  putchar( ',' );
538 
539  ++datapos;
540 
541  printf( "%5d", value );
542  }
Definition: link.h:174
#define printf
Definition: epicsStdio.h:41
#define putchar
Definition: epicsStdio.h:51
int datapos
Definition: flex.c:71
#define NUMDATAITEMS
Definition: flexdef.h:99
#define stdout
Definition: epicsStdio.h:30
void dataflush(void)
Definition: misc.c:312
void mkdeftbl ( void  )

Definition at line 467 of file tblcmp.c.

468 {
469  int i;
470 
471  jamstate = lastdfa + 1;
472 
473  ++tblend; /* room for transition on end-of-buffer character */
474 
475  if ( tblend + numecs > current_max_xpairs )
476  expand_nxt_chk();
477 
478  /* add in default end-of-buffer transition */
480  chk[tblend] = jamstate;
481 
482  for ( i = 1; i <= numecs; ++i )
483  {
484  nxt[tblend + i] = 0;
485  chk[tblend + i] = jamstate;
486  }
487 
488  jambase = tblend;
489 
490  base[jamstate] = jambase;
491  def[jamstate] = 0;
492 
493  tblend += numecs;
494  ++numtemps;
495  }
int jambase
Definition: flex.c:95
int i
Definition: scan.c:967
int tblend
Definition: flex.c:92
int lastdfa
Definition: flex.c:91
int numtemps
Definition: flex.c:81
int end_of_buffer_state
Definition: flex.c:105
int jamstate
Definition: flex.c:95
int * nxt
Definition: flex.c:91
int * base
Definition: flex.c:92
int * def
Definition: flex.c:92
int numecs
Definition: flex.c:83
int * chk
Definition: flex.c:91
int current_max_xpairs
Definition: flex.c:89
void expand_nxt_chk(void)
Definition: tblcmp.c:299
void mkeccl ( Char  [],
int  ,
int  [],
int  [],
int  ,
int   
)
void mkechar ( int  ,
int  [],
int  [] 
)

Definition at line 328 of file ecs.c.

329 {
330  /* if until now the character has been a proper subset of
331  * an equivalence class, break it away to create a new ec
332  */
333 
334  if ( fwd[tch] != NIL )
335  bck[fwd[tch]] = bck[tch];
336 
337  if ( bck[tch] != NIL )
338  fwd[bck[tch]] = fwd[tch];
339 
340  fwd[tch] = NIL;
341  bck[tch] = NIL;
342  }
#define NIL
Definition: flexdef.h:153
int mkopt ( int  )

Definition at line 405 of file nfa.c.

406 {
407  int eps;
408 
409  if ( ! SUPER_FREE_EPSILON(finalst[mach]) )
410  {
411  eps = mkstate( SYM_EPSILON );
412  mach = link_machines( mach, eps );
413  }
414 
415  /* can't skimp on the following if FREE_EPSILON(mach) is true because
416  * some state interior to "mach" might point back to the beginning
417  * for a closure
418  */
419  eps = mkstate( SYM_EPSILON );
420  mach = link_machines( eps, mach );
421 
422  mkxtion( mach, finalst[mach] );
423 
424  return ( mach );
425  }
#define SYM_EPSILON
Definition: flexdef.h:192
int * finalst
Definition: flex.c:77
int mkstate(int sym)
Definition: nfa.c:578
int link_machines(int first, int last)
Definition: nfa.c:283
void mkxtion(int, int)
Definition: nfa.c:648
#define SUPER_FREE_EPSILON(state)
Definition: flexdef.h:120
int mkor ( int  ,
int   
)

Definition at line 442 of file nfa.c.

443 {
444  int eps, orend;
445 
446  if ( first == NIL )
447  return ( second );
448 
449  else if ( second == NIL )
450  return ( first );
451 
452  else
453  {
454  /* see comment in mkopt() about why we can't use the first state
455  * of "first" or "second" if they satisfy "FREE_EPSILON"
456  */
457  eps = mkstate( SYM_EPSILON );
458 
459  first = link_machines( eps, first );
460 
461  mkxtion( first, second );
462 
463  if ( SUPER_FREE_EPSILON(finalst[first]) &&
464  accptnum[finalst[first]] == NIL )
465  {
466  orend = finalst[first];
467  mkxtion( finalst[second], orend );
468  }
469 
470  else if ( SUPER_FREE_EPSILON(finalst[second]) &&
471  accptnum[finalst[second]] == NIL )
472  {
473  orend = finalst[second];
474  mkxtion( finalst[first], orend );
475  }
476 
477  else
478  {
479  eps = mkstate( SYM_EPSILON );
480 
481  first = link_machines( first, eps );
482  orend = finalst[first];
483 
484  mkxtion( finalst[second], orend );
485  }
486  }
487 
488  finalst[first] = orend;
489  return ( first );
490  }
#define SYM_EPSILON
Definition: flexdef.h:192
#define NIL
Definition: flexdef.h:153
int * finalst
Definition: flex.c:77
int * accptnum
Definition: flex.c:78
int mkstate(int sym)
Definition: nfa.c:578
int link_machines(int first, int last)
Definition: nfa.c:283
void mkxtion(int, int)
Definition: nfa.c:648
#define SUPER_FREE_EPSILON(state)
Definition: flexdef.h:120
int mkposcl ( int  )

Definition at line 501 of file nfa.c.

502 {
503  int eps;
504 
505  if ( SUPER_FREE_EPSILON(finalst[state]) )
506  {
507  mkxtion( finalst[state], state );
508  return ( state );
509  }
510 
511  else
512  {
513  eps = mkstate( SYM_EPSILON );
514  mkxtion( eps, state );
515  return ( link_machines( state, eps ) );
516  }
517  }
#define SYM_EPSILON
Definition: flexdef.h:192
int * finalst
Definition: flex.c:77
int mkstate(int sym)
Definition: nfa.c:578
int link_machines(int first, int last)
Definition: nfa.c:283
void mkxtion(int, int)
Definition: nfa.c:648
#define SUPER_FREE_EPSILON(state)
Definition: flexdef.h:120
int mkrep ( int  ,
int  ,
int   
)

Definition at line 532 of file nfa.c.

533 {
534  int base_mach, tail, copy, i;
535 
536  base_mach = copysingl( mach, lb - 1 );
537 
538  if ( ub == INFINITY )
539  {
540  copy = dupmachine( mach );
541  mach = link_machines( mach,
542  link_machines( base_mach, mkclos( copy ) ) );
543  }
544 
545  else
546  {
547  tail = mkstate( SYM_EPSILON );
548 
549  for ( i = lb; i < ub; ++i )
550  {
551  copy = dupmachine( mach );
552  tail = mkopt( link_machines( copy, tail ) );
553  }
554 
555  mach = link_machines( mach, link_machines( base_mach, tail ) );
556  }
557 
558  return ( mach );
559  }
int i
Definition: scan.c:967
#define SYM_EPSILON
Definition: flexdef.h:192
void copy(PVValueArray< T > &pvFrom, size_t fromOffset, size_t fromStride, PVValueArray< T > &pvTo, size_t toOffset, size_t toStride, size_t count)
Copy a subarray from one scalar array to another.
int dupmachine(int)
Definition: nfa.c:158
#define INFINITY
Definition: flexdef.h:158
int mkstate(int sym)
Definition: nfa.c:578
int link_machines(int first, int last)
Definition: nfa.c:283
int copysingl(int singl, int num)
Definition: nfa.c:86
int mkclos(int state)
Definition: nfa.c:385
int mkopt(int mach)
Definition: nfa.c:405
int mkstate ( int  )

Definition at line 578 of file nfa.c.

579 {
580  if ( ++lastnfa >= current_mns )
581  {
582  if ( (current_mns += MNS_INCREMENT) >= MAXIMUM_MNS )
583  lerrif( "input rules are too complicated (>= %d NFA states)",
584  current_mns );
585 
586  ++num_reallocs;
587 
597  }
598 
602  transchar[lastnfa] = sym;
605  accptnum[lastnfa] = NIL;
608 
609  /* fix up equivalence classes base on this transition. Note that any
610  * character which has its own transition gets its own equivalence class.
611  * Thus only characters which are only in character classes have a chance
612  * at being in the same equivalence class. E.g. "a|b" puts 'a' and 'b'
613  * into two different equivalence classes. "[ab]" puts them in the same
614  * equivalence class (barring other differences elsewhere in the input).
615  */
616 
617  if ( sym < 0 )
618  {
619  /* we don't have to update the equivalence classes since that was
620  * already done when the ccl was created for the first time
621  */
622  }
623 
624  else if ( sym == SYM_EPSILON )
625  ++numeps;
626 
627  else
628  {
629  if ( useecs )
630  /* map NUL's to csize */
631  mkechar( sym ? sym : csize, nextecm, ecgroup );
632  }
633 
634  return ( lastnfa );
635  }
#define MAXIMUM_MNS
Definition: flexdef.h:182
int ecgroup[CSIZE+1]
Definition: flex.c:83
int * firstst
Definition: flex.c:77
#define SYM_EPSILON
Definition: flexdef.h:192
int num_reallocs
Definition: flex.c:100
int nextecm[CSIZE+1]
Definition: flex.c:83
#define NIL
Definition: flexdef.h:153
int numeps
Definition: flex.c:100
int current_state_type
Definition: flex.c:79
int csize
Definition: flex.c:68
int num_rules
Definition: flex.c:76
int useecs
Definition: flex.c:67
int * finalst
Definition: flex.c:77
int current_mns
Definition: flex.c:76
void lerrif(char[], int)
int * accptnum
Definition: flex.c:78
int * state_type
Definition: flex.c:78
#define reallocate_integer_array(array, size)
Definition: flexdef.h:584
int * assoc_rule
Definition: flex.c:78
int * trans2
Definition: flex.c:77
int * trans1
Definition: flex.c:77
#define NO_TRANSITION
Definition: flexdef.h:156
int lastnfa
Definition: flex.c:76
#define MNS_INCREMENT
Definition: flexdef.h:171
int * lastst
Definition: flex.c:77
int * transchar
Definition: flex.c:77
void mkechar(int tch, int fwd[], int bck[])
Definition: ecs.c:328
int myctoi ( Char  [])
void ndinstal ( char  [],
Char  [] 
)
void new_rule ( void  )

Definition at line 674 of file nfa.c.

675 {
676  if ( ++num_rules >= current_max_rules )
677  {
678  ++num_reallocs;
681  rule_linenum =
683  }
684 
685  if ( num_rules > MAX_RULE )
686  lerrif( "too many rules (> %d)!", MAX_RULE );
687 
689  }
int * rule_type
Definition: flex.c:78
#define MAX_RULE
Definition: flexdef.h:147
int num_reallocs
Definition: flex.c:100
int linenum
Definition: flex.c:71
int current_max_rules
Definition: flex.c:76
int * rule_linenum
Definition: flex.c:78
#define MAX_RULES_INCREMENT
Definition: flexdef.h:168
int num_rules
Definition: flex.c:76
void lerrif(char[], int)
#define reallocate_integer_array(array, size)
Definition: flexdef.h:584
void ntod ( void  )

Definition at line 398 of file dfa.c.

399 {
400  int *accset, ds, nacc, newds;
401  int sym, hashval, numstates, dsize;
402  int num_full_table_rows = 0; /* used only for -f */
403  int *nset, *dset;
404  int targptr, totaltrans, i, comstate, comfreq, targ;
405  int *epsclosure(int *t, int *ns_addr, int *accset, int *nacc_addr, int *hv_addr);
406  int snstods(int *sns, int numstates, int *accset, int nacc, int hashval, int *newds_addr);
407  int symlist[CSIZE + 1];
408  int num_start_states;
409  int todo_head, todo_next;
410 
411  /* note that the following are indexed by *equivalence classes*
412  * and not by characters. Since equivalence classes are indexed
413  * beginning with 1, even if the scanner accepts NUL's, this
414  * means that (since every character is potentially in its own
415  * equivalence class) these arrays must have room for indices
416  * from 1 to CSIZE, so their size must be CSIZE + 1.
417  */
418  int duplist[CSIZE + 1], state[CSIZE + 1];
419  int targfreq[CSIZE + 1], targstate[CSIZE + 1];
420 
421  /* this is so find_table_space(...) will know where to start looking in
422  * chk/nxt for unused records for space to put in the state
423  */
424  if ( fullspd )
425  firstfree = 0;
426 
427  accset = allocate_integer_array( num_rules + 1 );
429 
430  /* the "todo" queue is represented by the head, which is the DFA
431  * state currently being processed, and the "next", which is the
432  * next DFA state number available (not in use). We depend on the
433  * fact that snstods() returns DFA's \in increasing order/, and thus
434  * need only know the bounds of the dfas to be processed.
435  */
436  todo_head = todo_next = 0;
437 
438  for ( i = 0; i <= csize; ++i )
439  {
440  duplist[i] = NIL;
441  symlist[i] = false;
442  }
443 
444  for ( i = 0; i <= num_rules; ++i )
445  accset[i] = NIL;
446 
447  if ( trace )
448  {
449  dumpnfa( scset[1] );
450  fputs( "\n\nDFA Dump:\n\n", stderr );
451  }
452 
453  inittbl();
454 
455  /* check to see whether we should build a separate table for transitions
456  * on NUL characters. We don't do this for full-speed (-F) scanners,
457  * since for them we don't have a simple state number lying around with
458  * which to index the table. We also don't bother doing it for scanners
459  * unless (1) NUL is in its own equivalence class (indicated by a
460  * positive value of ecgroup[NUL]), (2) NUL's equilvalence class is
461  * the last equivalence class, and (3) the number of equivalence classes
462  * is the same as the number of characters. This latter case comes about
463  * when useecs is false or when its true but every character still
464  * manages to land in its own class (unlikely, but it's cheap to check
465  * for). If all these things are true then the character code needed
466  * to represent NUL's equivalence class for indexing the tables is
467  * going to take one more bit than the number of characters, and therefore
468  * we won't be assured of being able to fit it into a YY_CHAR variable.
469  * This rules out storing the transitions in a compressed table, since
470  * the code for interpreting them uses a YY_CHAR variable (perhaps it
471  * should just use an integer, though; this is worth pondering ... ###).
472  *
473  * Finally, for full tables, we want the number of entries in the
474  * table to be a power of two so the array references go fast (it
475  * will just take a shift to compute the major index). If encoding
476  * NUL's transitions in the table will spoil this, we give it its
477  * own table (note that this will be the case if we're not using
478  * equivalence classes).
479  */
480 
481  /* note that the test for ecgroup[0] == numecs below accomplishes
482  * both (1) and (2) above
483  */
484  if ( ! fullspd && ecgroup[0] == numecs )
485  { /* NUL is alone in its equivalence class, which is the last one */
486  int use_NUL_table = (numecs == csize);
487 
488  if ( fulltbl && ! use_NUL_table )
489  { /* we still may want to use the table if numecs is a power of 2 */
490  int power_of_two;
491 
492  for ( power_of_two = 1; power_of_two <= csize; power_of_two *= 2 )
493  if ( numecs == power_of_two )
494  {
495  use_NUL_table = true;
496  break;
497  }
498  }
499 
500  if ( use_NUL_table )
502  /* from now on, nultrans != nil indicates that we're
503  * saving null transitions for later, separate encoding
504  */
505  }
506 
507 
508  if ( fullspd )
509  {
510  for ( i = 0; i <= numecs; ++i )
511  state[i] = 0;
512  place_state( state, 0, 0 );
513  }
514 
515  else if ( fulltbl )
516  {
517  if ( nultrans )
518  /* we won't be including NUL's transitions in the table,
519  * so build it for entries from 0 .. numecs - 1
520  */
521  num_full_table_rows = numecs;
522 
523  else
524  /* take into account the fact that we'll be including
525  * the NUL entries in the transition table. Build it
526  * from 0 .. numecs.
527  */
528  num_full_table_rows = numecs + 1;
529 
530  /* declare it "short" because it's a real long-shot that that
531  * won't be large enough.
532  */
533  printf( "static short int yy_nxt[][%d] =\n {\n",
534  /* '}' so vi doesn't get too confused */
535  num_full_table_rows );
536 
537  /* generate 0 entries for state #0 */
538  for ( i = 0; i < num_full_table_rows; ++i )
539  mk2data( 0 );
540 
541  /* force ',' and dataflush() next call to mk2data */
543 
544  /* force extra blank line next dataflush() */
546  }
547 
548  /* create the first states */
549 
550  num_start_states = lastsc * 2;
551 
552  for ( i = 1; i <= num_start_states; ++i )
553  {
554  numstates = 1;
555 
556  /* for each start condition, make one state for the case when
557  * we're at the beginning of the line (the '%' operator) and
558  * one for the case when we're not
559  */
560  if ( i % 2 == 1 )
561  nset[numstates] = scset[(i / 2) + 1];
562  else
563  nset[numstates] = mkbranch( scbol[i / 2], scset[i / 2] );
564 
565  nset = epsclosure( nset, &numstates, accset, &nacc, &hashval );
566 
567  if ( snstods( nset, numstates, accset, nacc, hashval, &ds ) )
568  {
569  numas += nacc;
570  totnst += numstates;
571  ++todo_next;
572 
573  if ( variable_trailing_context_rules && nacc > 0 )
574  check_trailing_context( nset, numstates, accset, nacc );
575  }
576  }
577 
578  if ( ! fullspd )
579  {
580  if ( ! snstods( nset, 0, accset, 0, 0, &end_of_buffer_state ) )
581  flexfatal( "could not create unique end-of-buffer state" );
582 
583  ++numas;
584  ++num_start_states;
585  ++todo_next;
586  }
587 
588  while ( todo_head < todo_next )
589  {
590  targptr = 0;
591  totaltrans = 0;
592 
593  for ( i = 1; i <= numecs; ++i )
594  state[i] = 0;
595 
596  ds = ++todo_head;
597 
598  dset = dss[ds];
599  dsize = dfasiz[ds];
600 
601  if ( trace )
602  fprintf( stderr, "state # %d:\n", ds );
603 
604  sympartition( dset, dsize, symlist, duplist );
605 
606  for ( sym = 1; sym <= numecs; ++sym )
607  {
608  if ( symlist[sym] )
609  {
610  symlist[sym] = 0;
611 
612  if ( duplist[sym] == NIL )
613  { /* symbol has unique out-transitions */
614  numstates = symfollowset( dset, dsize, sym, nset );
615  nset = epsclosure( nset, &numstates, accset,
616  &nacc, &hashval );
617 
618  if ( snstods( nset, numstates, accset,
619  nacc, hashval, &newds ) )
620  {
621  totnst = totnst + numstates;
622  ++todo_next;
623  numas += nacc;
624 
625  if ( variable_trailing_context_rules && nacc > 0 )
626  check_trailing_context( nset, numstates,
627  accset, nacc );
628  }
629 
630  state[sym] = newds;
631 
632  if ( trace )
633  fprintf( stderr, "\t%d\t%d\n", sym, newds );
634 
635  targfreq[++targptr] = 1;
636  targstate[targptr] = newds;
637  ++numuniq;
638  }
639 
640  else
641  {
642  /* sym's equivalence class has the same transitions
643  * as duplist(sym)'s equivalence class
644  */
645  targ = state[duplist[sym]];
646  state[sym] = targ;
647 
648  if ( trace )
649  fprintf( stderr, "\t%d\t%d\n", sym, targ );
650 
651  /* update frequency count for destination state */
652 
653  i = 0;
654  while ( targstate[++i] != targ )
655  ;
656 
657  ++targfreq[i];
658  ++numdup;
659  }
660 
661  ++totaltrans;
662  duplist[sym] = NIL;
663  }
664  }
665 
666  numsnpairs = numsnpairs + totaltrans;
667 
668  if ( caseins && ! useecs )
669  {
670  int j;
671 
672  for ( i = 'A', j = 'a'; i <= 'Z'; ++i, ++j )
673  state[i] = state[j];
674  }
675 
676  if ( ds > num_start_states )
677  check_for_backtracking( ds, state );
678 
679  if ( nultrans )
680  {
681  nultrans[ds] = state[NUL_ec];
682  state[NUL_ec] = 0; /* remove transition */
683  }
684 
685  if ( fulltbl )
686  {
687  /* supply array's 0-element */
688  if ( ds == end_of_buffer_state )
690  else
692 
693  for ( i = 1; i < num_full_table_rows; ++i )
694  /* jams are marked by negative of state number */
695  mk2data( state[i] ? state[i] : -ds );
696 
697  /* force ',' and dataflush() next call to mk2data */
699 
700  /* force extra blank line next dataflush() */
702  }
703 
704  else if ( fullspd )
705  place_state( state, ds, totaltrans );
706 
707  else if ( ds == end_of_buffer_state )
708  /* special case this state to make sure it does what it's
709  * supposed to, i.e., jam on end-of-buffer
710  */
711  stack1( ds, 0, 0, JAMSTATE );
712 
713  else /* normal, compressed state */
714  {
715  /* determine which destination state is the most common, and
716  * how many transitions to it there are
717  */
718 
719  comfreq = 0;
720  comstate = 0;
721 
722  for ( i = 1; i <= targptr; ++i )
723  if ( targfreq[i] > comfreq )
724  {
725  comfreq = targfreq[i];
726  comstate = targstate[i];
727  }
728 
729  bldtbl( state, ds, totaltrans, comstate, comfreq );
730  }
731  }
732 
733  if ( fulltbl )
734  dataend();
735 
736  else if ( ! fullspd )
737  {
738  cmptmps(); /* create compressed template entries */
739 
740  /* create tables for all the states with only one out-transition */
741  while ( onesp > 0 )
742  {
743  mk1tbl( onestate[onesp], onesym[onesp], onenext[onesp],
744  onedef[onesp] );
745  --onesp;
746  }
747 
748  mkdeftbl();
749  }
750  }
int ** dss
Definition: flex.c:92
void stack1(int, int, int, int)
Definition: tblcmp.c:851
int ecgroup[CSIZE+1]
Definition: flex.c:83
int i
Definition: scan.c:967
int fullspd
Definition: flex.c:68
int variable_trailing_context_rules
Definition: flex.c:80
int numuniq
Definition: flex.c:101
void mk1tbl(int, int, int, int)
Definition: tblcmp.c:647
int symfollowset(int[], int, int, int[])
Definition: dfa.c:887
#define printf
Definition: epicsStdio.h:41
int numsnpairs
Definition: flex.c:95
void sympartition(int[], int, int[], int[])
Definition: dfa.c:971
#define NIL
Definition: flexdef.h:153
void cmptmps(void)
Definition: tblcmp.c:228
void inittbl(void)
Definition: tblcmp.c:430
struct dset dset
#define NUMDATALINES
Definition: flexdef.h:104
void check_trailing_context(int *nfa_states, int num_states, int *accset, int nacc)
Definition: dfa.c:103
int onestate[ONE_STACK_SIZE]
Definition: flex.c:74
int csize
Definition: flex.c:68
int caseins
Definition: flex.c:67
int num_rules
Definition: flex.c:76
#define allocate_integer_array(size)
Definition: flexdef.h:581
int useecs
Definition: flex.c:67
int * dfasiz
Definition: flex.c:92
void check_for_backtracking(int ds, int state[])
Definition: dfa.c:59
int firstfree
Definition: flex.c:92
void dataend(void)
Definition: misc.c:292
int onesp
Definition: flex.c:75
int * scset
Definition: flex.c:87
int numdup
Definition: flex.c:101
int * scbol
Definition: flex.c:87
int current_max_dfa_size
Definition: flex.c:89
int NUL_ec
Definition: flex.c:92
int onesym[ONE_STACK_SIZE]
Definition: flex.c:74
int end_of_buffer_state
Definition: flex.c:105
int datapos
Definition: flex.c:71
#define NUMDATAITEMS
Definition: flexdef.h:99
int * epsclosure(int *t, int *ns_addr, int accset[], int *nacc_addr, int *hv_addr)
Definition: dfa.c:249
int onedef[ONE_STACK_SIZE]
Definition: flex.c:75
int onenext[ONE_STACK_SIZE]
Definition: flex.c:75
void flexfatal(char[])
int trace
Definition: flex.c:66
int lastsc
Definition: flex.c:87
int * nultrans
Definition: flex.c:92
int current_max_dfas
Definition: flex.c:90
int mkbranch(int, int)
Definition: nfa.c:358
int snstods(int sns[], int numstates, int accset[], int nacc, int hashval, int *newds_addr)
Definition: dfa.c:763
int totnst
Definition: flex.c:101
int dataline
Definition: flex.c:71
#define JAMSTATE
Definition: flexdef.h:176
void bldtbl(int[], int, int, int, int)
#define stderr
Definition: epicsStdio.h:32
int numecs
Definition: flex.c:83
int fulltbl
Definition: flex.c:67
void dumpnfa(int)
Definition: nfa.c:106
#define CSIZE
Definition: flexdef.h:58
void mkdeftbl(void)
Definition: tblcmp.c:467
int numas
Definition: flex.c:94
void mk2data(int)
Definition: misc.c:494
void place_state(int *, int, int)
Definition: tblcmp.c:807
void pinpoint_message ( char  [])
void place_state ( int *  ,
int  ,
int   
)

Definition at line 807 of file tblcmp.c.

808 {
809  int i;
810  int *state_ptr;
811  int position = find_table_space( state, transnum );
812 
813  /* base is the table of start positions */
814  base[statenum] = position;
815 
816  /* put in action number marker; this non-zero number makes sure that
817  * find_table_space() knows that this position in chk/nxt is taken
818  * and should not be used for another accepting number in another state
819  */
820  chk[position - 1] = 1;
821 
822  /* put in end-of-buffer marker; this is for the same purposes as above */
823  chk[position] = 1;
824 
825  /* place the state into chk and nxt */
826  state_ptr = &state[1];
827 
828  for ( i = 1; i <= numecs; ++i, ++state_ptr )
829  if ( *state_ptr != 0 )
830  {
831  chk[position + i] = i;
832  nxt[position + i] = *state_ptr;
833  }
834 
835  if ( position + numecs > tblend )
836  tblend = position + numecs;
837  }
int i
Definition: scan.c:967
int tblend
Definition: flex.c:92
int find_table_space(int *state, int numtrans)
Definition: tblcmp.c:334
int * nxt
Definition: flex.c:91
int * base
Definition: flex.c:92
int numecs
Definition: flex.c:83
int * chk
Definition: flex.c:91
void* reallocate_array ( void *  array,
int  size,
int  element_size 
)

Definition at line 707 of file misc.c.

708 {
709  void *new_array;
710 
711  /* same worry as in allocate_array(): */
712  if ( size * element_size <= 0 )
713  flexfatal( "attempt to increase array size by less than 1 byte" );
714 
715  new_array =
716  (void *) realloc( (char *)array, (unsigned) (size * element_size ));
717 
718  if ( new_array == NULL )
719  flexfatal( "attempt to increase array size failed" );
720 
721  return ( new_array );
722  }
#define NULL
Definition: catime.c:38
void flexfatal(char *msg)
Definition: misc.c:352
void scinstal ( char  [],
int   
)
int sclookup ( char  [])
void set_input_file ( char *  )

Definition at line 2233 of file scan.c.

2236  {
2237  if ( file )
2238  {
2239  infilename = file;
2240  yyin = fopen( infilename, "r" );
2241 
2242  if ( yyin == NULL )
2243  lerrsf( "can't open %s", file );
2244  }
2245 
2246  else
2247  {
2248  yyin = stdin;
2249  infilename = "<stdin>";
2250  }
2251  }
#define NULL
Definition: catime.c:38
void lerrsf(char[], char[])
FILE * yyin
Definition: scan.c:290
char * infilename
Definition: flex.c:73
#define stdin
Definition: epicsStdio.h:28
void skelout ( void  )

Definition at line 734 of file misc.c.

735 {
736  char buf[MAXLINE];
737 
738  while ( fgets( buf, MAXLINE, skelfile ) != NULL )
739  if ( buf[0] == '%' && buf[1] == '%' )
740  break;
741  else
742  fputs( buf, stdout );
743  }
#define NULL
Definition: catime.c:38
#define stdout
Definition: epicsStdio.h:30
#define MAXLINE
Definition: flexdef.h:72
FILE * skelfile
Definition: flex.c:72
void stack1 ( int  ,
int  ,
int  ,
int   
)

Definition at line 851 of file tblcmp.c.

852 {
853  if ( onesp >= ONE_STACK_SIZE - 1 )
854  mk1tbl( statenum, sym, nextstate, deflink );
855 
856  else
857  {
858  ++onesp;
859  onestate[onesp] = statenum;
860  onesym[onesp] = sym;
861  onenext[onesp] = nextstate;
862  onedef[onesp] = deflink;
863  }
864  }
int onestate[ONE_STACK_SIZE]
Definition: flex.c:74
#define ONE_STACK_SIZE
Definition: flexdef.h:197
int onesp
Definition: flex.c:75
void mk1tbl(int state, int sym, int onenxt, int onedef)
Definition: tblcmp.c:647
int onesym[ONE_STACK_SIZE]
Definition: flex.c:74
int onedef[ONE_STACK_SIZE]
Definition: flex.c:75
int onenext[ONE_STACK_SIZE]
Definition: flex.c:75
void synerr ( char  [])
void transition_struct_out ( int  ,
int   
)

Definition at line 756 of file misc.c.

757 {
758  printf( "%7d, %5d,", element_v, element_n );
759 
761 
762  if ( datapos >= 75 )
763  {
764  putchar( '\n' );
765 
766  if ( ++dataline % 10 == 0 )
767  putchar( '\n' );
768 
769  datapos = 0;
770  }
771  }
#define printf
Definition: epicsStdio.h:41
#define putchar
Definition: epicsStdio.h:51
int datapos
Definition: flex.c:71
#define TRANS_STRUCT_PRINT_LENGTH
Definition: flexdef.h:107
int dataline
Definition: flex.c:71
int yylex ( )

Definition at line 56 of file yylex.c.

57 {
58  int toktype;
59  static int beglin = false;
60 
61  if ( eofseen )
62  toktype = EOF;
63  else
64  toktype = flexscan();
65 
66  if ( toktype == EOF || toktype == 0 )
67  {
68  eofseen = 1;
69 
70  if ( sectnum == 1 )
71  {
72  synerr( "premature EOF" );
73  sectnum = 2;
74  toktype = SECTEND;
75  }
76 
77  else if ( sectnum == 2 )
78  {
79  sectnum = 3;
80  toktype = 0;
81  }
82 
83  else
84  toktype = 0;
85  }
86 
87  if ( trace )
88  {
89  if ( beglin )
90  {
91  fprintf( stderr, "%d\t", num_rules + 1 );
92  beglin = 0;
93  }
94 
95  switch ( toktype )
96  {
97  case '<':
98  case '>':
99  case '^':
100  case '$':
101  case '"':
102  case '[':
103  case ']':
104  case '{':
105  case '}':
106  case '|':
107  case '(':
108  case ')':
109  case '-':
110  case '/':
111  case '\\':
112  case '?':
113  case '.':
114  case '*':
115  case '+':
116  case ',':
117  (void) putc( toktype, stderr );
118  break;
119 
120  case '\n':
121  (void) putc( '\n', stderr );
122 
123  if ( sectnum == 2 )
124  beglin = 1;
125 
126  break;
127 
128  case SCDECL:
129  fputs( "%s", stderr );
130  break;
131 
132  case XSCDECL:
133  fputs( "%x", stderr );
134  break;
135 
136  case WHITESPACE:
137  (void) putc( ' ', stderr );
138  break;
139 
140  case SECTEND:
141  fputs( "%%\n", stderr );
142 
143  /* we set beglin to be true so we'll start
144  * writing out numbers as we echo rules. flexscan() has
145  * already assigned sectnum
146  */
147 
148  if ( sectnum == 2 )
149  beglin = 1;
150 
151  break;
152 
153  case NAME:
154  fprintf( stderr, "'%s'", nmstr );
155  break;
156 
157  case CHAR:
158  switch ( yylval )
159  {
160  case '<':
161  case '>':
162  case '^':
163  case '$':
164  case '"':
165  case '[':
166  case ']':
167  case '{':
168  case '}':
169  case '|':
170  case '(':
171  case ')':
172  case '-':
173  case '/':
174  case '\\':
175  case '?':
176  case '.':
177  case '*':
178  case '+':
179  case ',':
180  fprintf( stderr, "\\%c", yylval );
181  break;
182 
183  default:
184  if ( ! isascii( yylval ) || ! isprint( yylval ) )
185  fprintf( stderr, "\\%.3o", yylval );
186  else
187  (void) putc( yylval, stderr );
188  break;
189  }
190 
191  break;
192 
193  case NUMBER:
194  fprintf( stderr, "%d", yylval );
195  break;
196 
197  case PREVCCL:
198  fprintf( stderr, "[%d]", yylval );
199  break;
200 
201  case EOF_OP:
202  fprintf( stderr, "<<EOF>>" );
203  break;
204 
205  case 0:
206  fprintf( stderr, "End Marker" );
207  break;
208 
209  default:
210  fprintf( stderr, "*Something Weird* - tok: %d val: %d\n",
211  toktype, yylval );
212  break;
213  }
214  }
215 
216  return ( toktype );
217 }
char nmstr[MAXLINE]
Definition: flex.c:99
int num_rules
Definition: flex.c:76
void synerr(char[])
int flexscan()
int trace
Definition: flex.c:66
#define stderr
Definition: epicsStdio.h:32
#define isascii(c)
Definition: yylex.c:43
int eofseen
Definition: flex.c:66
int sectnum
Definition: flex.c:100
int yywrap ( )

Variable Documentation

int* accptnum

Definition at line 78 of file flex.c.

int* accsiz

Definition at line 94 of file flex.c.

int * actvsc

Definition at line 87 of file flex.c.

int * assoc_rule

Definition at line 78 of file flex.c.

FILE * backtrack_file

Definition at line 104 of file flex.c.

int backtrack_report

Definition at line 68 of file flex.c.

int* base

Definition at line 92 of file flex.c.

int bol_needed

Definition at line 102 of file flex.c.

int caseins

Definition at line 67 of file flex.c.

int * ccllen

Definition at line 96 of file flex.c.

int * cclmap

Definition at line 96 of file flex.c.

int * cclng

Definition at line 96 of file flex.c.

int cclreuse

Definition at line 96 of file flex.c.

struct hash_entry* ccltab[CCL_HASH_SIZE]

Definition at line 47 of file sym.c.

Char* ccltbl

Definition at line 98 of file flex.c.

int * chk

Definition at line 91 of file flex.c.

int continued_action

Definition at line 69 of file flex.c.

int csize

Definition at line 68 of file flex.c.

int current_max_ccl_tbl_size

Definition at line 97 of file flex.c.

int current_max_dfa_size

Definition at line 89 of file flex.c.

int current_max_dfas

Definition at line 90 of file flex.c.

int current_max_rules

Definition at line 76 of file flex.c.

int current_max_scs

Definition at line 87 of file flex.c.

int current_max_template_xpairs

Definition at line 90 of file flex.c.

int current_max_xpairs

Definition at line 89 of file flex.c.

int current_maxccls

Definition at line 96 of file flex.c.

int current_mns

Definition at line 76 of file flex.c.

int current_state_type

Definition at line 79 of file flex.c.

int dataline

Definition at line 71 of file flex.c.

int datapos

Definition at line 71 of file flex.c.

int ddebug

Definition at line 66 of file flex.c.

int * def

Definition at line 92 of file flex.c.

union dfaacc_union * dfaacc
int dfaeql

Definition at line 100 of file flex.c.

int * dfasiz

Definition at line 92 of file flex.c.

int * dhash

Definition at line 94 of file flex.c.

int ** dss

Definition at line 92 of file flex.c.

int ecgroup[CSIZE+1]

Definition at line 83 of file flex.c.

int end_of_buffer_state

Definition at line 105 of file flex.c.

char * endtime

Definition at line 99 of file flex.c.

int eofseen

Definition at line 66 of file flex.c.

int eps2

Definition at line 100 of file flex.c.

int * finalst

Definition at line 77 of file flex.c.

int firstfree

Definition at line 92 of file flex.c.

int firstprot

Definition at line 82 of file flex.c.

int* firstst

Definition at line 77 of file flex.c.

int fullspd

Definition at line 68 of file flex.c.

int fulltbl

Definition at line 67 of file flex.c.

int gen_line_dirs

Definition at line 68 of file flex.c.

int hshcol

Definition at line 100 of file flex.c.

int hshsave

Definition at line 101 of file flex.c.

char* infilename

Definition at line 73 of file flex.c.

char** input_files

Definition at line 106 of file flex.c.

int interactive

Definition at line 67 of file flex.c.

int jambase

Definition at line 95 of file flex.c.

int jamstate

Definition at line 95 of file flex.c.

int lastccl

Definition at line 96 of file flex.c.

int lastdfa

Definition at line 91 of file flex.c.

int lastnfa

Definition at line 76 of file flex.c.

int lastprot

Definition at line 82 of file flex.c.

int lastsc

Definition at line 87 of file flex.c.

int * lastst

Definition at line 77 of file flex.c.

int lasttemp
int linenum

Definition at line 71 of file flex.c.

Definition at line 45 of file sym.c.

int nextecm[CSIZE+1]

Definition at line 83 of file flex.c.

char nmstr[MAXLINE]

Definition at line 99 of file flex.c.

int NUL_ec

Definition at line 92 of file flex.c.

int * nultrans

Definition at line 92 of file flex.c.

int num_backtracking

Definition at line 102 of file flex.c.

int num_input_files

Definition at line 107 of file flex.c.

int num_reallocs

Definition at line 100 of file flex.c.

int num_rules

Definition at line 76 of file flex.c.

int num_xlations

Definition at line 86 of file flex.c.

int numas

Definition at line 94 of file flex.c.

int numdup

Definition at line 101 of file flex.c.

int numecs

Definition at line 83 of file flex.c.

int numeps

Definition at line 100 of file flex.c.

int nummecs

Definition at line 83 of file flex.c.

int nummt

Definition at line 100 of file flex.c.

int numprots

Definition at line 81 of file flex.c.

int numsnpairs

Definition at line 95 of file flex.c.

int numtemps

Definition at line 81 of file flex.c.

int numuniq

Definition at line 101 of file flex.c.

int * nxt

Definition at line 91 of file flex.c.

int onedef[ONE_STACK_SIZE]

Definition at line 75 of file flex.c.

int onenext[ONE_STACK_SIZE]

Definition at line 75 of file flex.c.

int onesp

Definition at line 75 of file flex.c.

int onestate[ONE_STACK_SIZE]

Definition at line 74 of file flex.c.

int onesym[ONE_STACK_SIZE]

Definition at line 74 of file flex.c.

int peakpairs

Definition at line 101 of file flex.c.

int performance_report

Definition at line 68 of file flex.c.

int printstats

Definition at line 66 of file flex.c.

char* program_name

Definition at line 108 of file flex.c.

int protcomst[MSP]

Definition at line 82 of file flex.c.

int protnext[MSP]

Definition at line 81 of file flex.c.

int protprev[MSP]

Definition at line 81 of file flex.c.

int protsave[PROT_SAVE_SIZE]

Definition at line 82 of file flex.c.

int prottbl[MSP]

Definition at line 81 of file flex.c.

int real_reject

Definition at line 69 of file flex.c.

int reject

Definition at line 69 of file flex.c.

int reject_really_used

Definition at line 70 of file flex.c.

int * rule_linenum

Definition at line 78 of file flex.c.

int * rule_type

Definition at line 78 of file flex.c.

int * scbol

Definition at line 87 of file flex.c.

int * sceof

Definition at line 87 of file flex.c.

char** scname

Definition at line 88 of file flex.c.

int * scset

Definition at line 87 of file flex.c.

Definition at line 46 of file sym.c.

int * scxclu

Definition at line 87 of file flex.c.

int sectnum

Definition at line 100 of file flex.c.

FILE* skelfile

Definition at line 72 of file flex.c.

int spprdflt

Definition at line 66 of file flex.c.

char* starttime

Definition at line 99 of file flex.c.

int * state_type

Definition at line 78 of file flex.c.

int syntaxerror

Definition at line 66 of file flex.c.

int tblend

Definition at line 92 of file flex.c.

int tecbck[CSIZE+1]

Definition at line 84 of file flex.c.

int tecfwd[CSIZE+1]

Definition at line 83 of file flex.c.

FILE * temp_action_file

Definition at line 103 of file flex.c.

int tmpuses

Definition at line 101 of file flex.c.

int * tnxt

Definition at line 91 of file flex.c.

int totnst

Definition at line 101 of file flex.c.

int trace

Definition at line 66 of file flex.c.

int * trans1

Definition at line 77 of file flex.c.

int * trans2

Definition at line 77 of file flex.c.

int * transchar

Definition at line 77 of file flex.c.

int useecs

Definition at line 67 of file flex.c.

int usemecs

Definition at line 67 of file flex.c.

int variable_trailing_context_rules

Definition at line 80 of file flex.c.

int* xlation

Definition at line 85 of file flex.c.

FILE * yyin = (FILE *) 0

Definition at line 290 of file scan.c.

int yymore_really_used

Definition at line 70 of file flex.c.

int yymore_used

Definition at line 69 of file flex.c.