Skip to content

Commit

Permalink
refactor: Make functions in dfa.c static.
Browse files Browse the repository at this point in the history
  • Loading branch information
Explorer09 authored and westes committed Apr 27, 2024
1 parent 518108e commit 1f27fff
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 24 deletions.
25 changes: 13 additions & 12 deletions src/dfa.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@

/* declare functions that have forward references */

void dump_associated_rules(FILE *, int);
void dump_transitions(FILE *, int[]);
void sympartition(int[], int, int[], int[]);
int symfollowset(int[], int, int, int[]);
static void dump_associated_rules(FILE *, int);
static void dump_transitions(FILE *, int[]);
static int snstods(int[], int, int[], int, int, int *);
static void sympartition(int[], int, int[], int[]);
static int symfollowset(int[], int, int, int[]);


/* check_for_backing_up - check a DFA state for backing up
Expand All @@ -49,7 +50,7 @@ int symfollowset(int[], int, int, int[]);
* indexed by equivalence class.
*/

void check_for_backing_up (int ds, int state[])
static void check_for_backing_up(int ds, int state[])
{
if ((reject && !dfaacc[ds].dfaacc_set) || (!reject && !dfaacc[ds].dfaacc_state)) { /* state is non-accepting */
++num_backing_up;
Expand Down Expand Up @@ -94,7 +95,7 @@ void check_for_backing_up (int ds, int state[])
* accset[1 .. nacc] is the list of accepting numbers for the DFA state.
*/

void check_trailing_context (int *nfa_states, int num_states, int *accset, int nacc)
static void check_trailing_context(int *nfa_states, int num_states, int *accset, int nacc)
{
int i, j;

Expand Down Expand Up @@ -132,7 +133,7 @@ void check_trailing_context (int *nfa_states, int num_states, int *accset, int n
* and writes a report to the given file.
*/

void dump_associated_rules (FILE *file, int ds)
static void dump_associated_rules(FILE *file, int ds)
{
int i, j;
int num_associated_rules = 0;
Expand Down Expand Up @@ -180,7 +181,7 @@ void dump_associated_rules (FILE *file, int ds)
* is done to the given file.
*/

void dump_transitions (FILE *file, int state[])
static void dump_transitions(FILE *file, int state[])
{
int i, ec;
int out_char_set[CSIZE];
Expand Down Expand Up @@ -226,7 +227,7 @@ void dump_transitions (FILE *file, int state[])
* hashval is the hash value for the dfa corresponding to the state set.
*/

int *epsclosure (int *t, int *ns_addr, int accset[], int *nacc_addr, int *hv_addr)
static int *epsclosure(int *t, int *ns_addr, int accset[], int *nacc_addr, int *hv_addr)
{
int stkpos, ns, tsp;
int numstates = *ns_addr, nacc, hashval, transsym, nfaccnum;
Expand Down Expand Up @@ -778,7 +779,7 @@ size_t ntod (void)
* On return, the dfa state number is in newds.
*/

int snstods (int sns[], int numstates, int accset[], int nacc, int hashval, int *newds_addr)
static int snstods(int sns[], int numstates, int accset[], int nacc, int hashval, int *newds_addr)
{
int didsort = 0;
int i, j;
Expand Down Expand Up @@ -899,7 +900,7 @@ int snstods (int sns[], int numstates, int accset[], int nacc, int hashval, int
* int transsym, int nset[current_max_dfa_size] );
*/

int symfollowset (int ds[], int dsize, int transsym, int nset[])
static int symfollowset(int ds[], int dsize, int transsym, int nset[])
{
int ns, tsp, sym, i, j, lenccl, ch, numstates, ccllist;

Expand Down Expand Up @@ -976,7 +977,7 @@ int symfollowset (int ds[], int dsize, int transsym, int nset[])
* int symlist[numecs], int duplist[numecs] );
*/

void sympartition (int ds[], int numstates, int symlist[], int duplist[])
static void sympartition(int ds[], int numstates, int symlist[], int duplist[])
{
int tch, i, j, k, ns, dupfwd[CSIZE + 1], lenccl, cclp, ich;

Expand Down
12 changes: 0 additions & 12 deletions src/flexdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -776,23 +776,11 @@ extern void list_character_set(FILE *, int[]);

/* from file dfa.c */

/* Check a DFA state for backing up. */
extern void check_for_backing_up(int, int[]);

/* Check to see if NFA state set constitutes "dangerous" trailing context. */
extern void check_trailing_context(int *, int, int *, int);

/* Construct the epsilon closure of a set of ndfa states. */
extern int *epsclosure(int *, int *, int[], int *, int *);

/* Increase the maximum number of dfas. */
extern void increase_max_dfas(void);

extern size_t ntod(void); /* convert a ndfa to a dfa */

/* Converts a set of ndfa states into a dfa state. */
extern int snstods(int[], int, int[], int, int, int *);


/* from file ecs.c */

Expand Down

0 comments on commit 1f27fff

Please sign in to comment.