Correct some error on static function declaration.
This commit is contained in:
parent
b31ac47714
commit
d87b482eac
@ -29,29 +29,7 @@ typedef struct lngth {
|
|||||||
} t_length, *p_length;
|
} t_length, *p_length;
|
||||||
|
|
||||||
void do_compute(void);
|
void do_compute(void);
|
||||||
void createsets(void);
|
|
||||||
void walk(p_set u, p_gram p);
|
|
||||||
void co_trans(int (*fc)(p_nont));
|
|
||||||
int nempty(p_nont p);
|
|
||||||
int empty(p_gram p);
|
int empty(p_gram p);
|
||||||
int nfirst(p_nont p);
|
|
||||||
int first(p_set setp, p_gram p, int flag);
|
|
||||||
int nfollow(p_nont p);
|
|
||||||
int follow(p_set setp, p_gram p);
|
|
||||||
void co_dirsymb(p_set setp, p_gram p);
|
|
||||||
void co_others(p_gram p);
|
|
||||||
int ncomplength(p_nont p);
|
|
||||||
int nc_nfirst(p_nont p);
|
|
||||||
STATIC int nc_nfollow(p_nont p);
|
|
||||||
void do_lengthcomp(void);
|
|
||||||
void complength(p_gram p, p_length le);
|
|
||||||
void add(p_length a, int c, int v);
|
|
||||||
int compare(p_length a, p_length b);
|
|
||||||
void setdefaults(p_gram p);
|
|
||||||
void do_contains(p_nont n);
|
|
||||||
void contains(p_gram p, p_set set);
|
|
||||||
int nsafes(p_nont p);
|
|
||||||
int do_safes(p_gram p, int safe, int *ch);
|
|
||||||
int t_safety(int rep, int count, int persistent, int safety);
|
int t_safety(int rep, int count, int persistent, int safety);
|
||||||
int t_after(int rep, int count, int outsafety);
|
int t_after(int rep, int count, int outsafety);
|
||||||
|
|
||||||
@ -158,4 +136,7 @@ char * vallookup(int s);
|
|||||||
char * cpy(int s, char * p, int inserted);
|
char * cpy(int s, char * p, int inserted);
|
||||||
void LLmessage(int d);
|
void LLmessage(int d);
|
||||||
|
|
||||||
|
/* grammar.c */
|
||||||
|
void save_grammar(FILE *f);
|
||||||
|
|
||||||
#endif /* LLGEN_H */
|
#endif /* LLGEN_H */
|
||||||
|
|||||||
@ -27,8 +27,34 @@
|
|||||||
|
|
||||||
#include "LLgen.h"
|
#include "LLgen.h"
|
||||||
|
|
||||||
|
static void createsets(void);
|
||||||
|
static void walk(p_set u, p_gram p);
|
||||||
|
static void co_trans(int (*fc)(p_nont));
|
||||||
|
static int nempty(p_nont p);
|
||||||
|
static int nfirst(p_nont p);
|
||||||
|
static int nc_nfirst(p_nont p);
|
||||||
|
static int first(p_set setp, p_gram p, int flag);
|
||||||
|
static int nc_nfollow(p_nont p);
|
||||||
|
static int nc_first(p_set setp, p_gram p, int flag);
|
||||||
|
static int nfollow(p_nont p);
|
||||||
|
static int follow(p_set setp, p_gram p);
|
||||||
|
static void co_dirsymb(p_set setp, p_gram p);
|
||||||
|
static void co_others(p_gram p);
|
||||||
|
static int ncomplength(p_nont p);
|
||||||
|
static void do_lengthcomp(void);
|
||||||
|
static void complength(p_gram p, p_length le);
|
||||||
|
static void add(p_length a, int c, int v);
|
||||||
|
static int compare(p_length a, p_length b);
|
||||||
|
static void setdefaults(p_gram p);
|
||||||
|
static void do_contains(p_nont n);
|
||||||
|
static void contains(p_gram p, p_set set);
|
||||||
|
static int nsafes(p_nont p);
|
||||||
|
static int do_safes(p_gram p, int safe, int *ch);
|
||||||
|
|
||||||
|
|
||||||
/* Defined in this file : */
|
/* Defined in this file : */
|
||||||
void do_compute(void) {
|
void do_compute(void)
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* Does all the work, by calling other routines (divide and conquer)
|
* Does all the work, by calling other routines (divide and conquer)
|
||||||
*/
|
*/
|
||||||
@ -122,7 +148,8 @@ void do_compute(void) {
|
|||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC void createsets() {
|
static void createsets()
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* Allocate space for the sets. Also determine which files use
|
* Allocate space for the sets. Also determine which files use
|
||||||
* which nonterminals, and determine which nonterminals can be
|
* which nonterminals, and determine which nonterminals can be
|
||||||
@ -168,7 +195,8 @@ STATIC void createsets() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC void walk(p_set u, p_gram p) {
|
static void walk(p_set u, p_gram p)
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* Walk through the grammar rule p, allocating sets
|
* Walk through the grammar rule p, allocating sets
|
||||||
*/
|
*/
|
||||||
@ -210,7 +238,8 @@ STATIC void walk(p_set u, p_gram p) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC void co_trans(int (*fc)(p_nont)) {
|
static void co_trans(int (*fc)(p_nont))
|
||||||
|
{
|
||||||
p_nont p;
|
p_nont p;
|
||||||
int change;
|
int change;
|
||||||
|
|
||||||
@ -222,7 +251,8 @@ STATIC void co_trans(int (*fc)(p_nont)) {
|
|||||||
} while (change);
|
} while (change);
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC int nempty(p_nont p) {
|
static int nempty(p_nont p)
|
||||||
|
{
|
||||||
if (!(p->n_flags & EMPTY) && empty(p->n_rule)) {
|
if (!(p->n_flags & EMPTY) && empty(p->n_rule)) {
|
||||||
p->n_flags |= EMPTY;
|
p->n_flags |= EMPTY;
|
||||||
return 1;
|
return 1;
|
||||||
@ -230,7 +260,8 @@ STATIC int nempty(p_nont p) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int empty(p_gram p) {
|
int empty(p_gram p)
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* Does the rule pointed to by p produce empty ?
|
* Does the rule pointed to by p produce empty ?
|
||||||
*/
|
*/
|
||||||
@ -266,17 +297,20 @@ int empty(p_gram p) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC int nfirst(p_nont p) {
|
static int nfirst(p_nont p)
|
||||||
|
{
|
||||||
return first(p->n_first, p->n_rule, 0);
|
return first(p->n_first, p->n_rule, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef NON_CORRECTING
|
#ifdef NON_CORRECTING
|
||||||
STATIC int nc_nfirst(p_nont p) {
|
static int nc_nfirst(p_nont p)
|
||||||
|
{
|
||||||
return nc_first(p->n_nc_first, p->n_rule, 0);
|
return nc_first(p->n_nc_first, p->n_rule, 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
STATIC int first(p_set setp, p_gram p, int flag) {
|
static int first(p_set setp, p_gram p, int flag)
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* Compute the FIRST set of rule p.
|
* Compute the FIRST set of rule p.
|
||||||
* If flag = 0, also the first sets for terms and alternations in
|
* If flag = 0, also the first sets for terms and alternations in
|
||||||
@ -354,7 +388,8 @@ STATIC int first(p_set setp, p_gram p, int flag) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef NON_CORRECTING
|
#ifdef NON_CORRECTING
|
||||||
STATIC int nc_first(p_set setp, p_gram p, int flag) {
|
static int nc_first(p_set setp, p_gram p, int flag)
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* Compute the non_corr FIRST set of rule p.
|
* Compute the non_corr FIRST set of rule p.
|
||||||
* If flag = 0, also the non_corr first sets for terms and
|
* If flag = 0, also the non_corr first sets for terms and
|
||||||
@ -366,7 +401,7 @@ STATIC int nc_first(p_set setp, p_gram p, int flag) {
|
|||||||
* first-sets of startsynbols in the %substart are used
|
* first-sets of startsynbols in the %substart are used
|
||||||
*/
|
*/
|
||||||
|
|
||||||
register s; /* Will gather return value */
|
int s; /* Will gather return value */
|
||||||
int noenter;/* when set, unables entering of elements into
|
int noenter;/* when set, unables entering of elements into
|
||||||
* setp. This is necessary to walk through the
|
* setp. This is necessary to walk through the
|
||||||
* rest of rule p.
|
* rest of rule p.
|
||||||
@ -460,11 +495,13 @@ STATIC int nc_first(p_set setp, p_gram p, int flag) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
STATIC int nfollow(p_nont p) {
|
static int nfollow(p_nont p)
|
||||||
|
{
|
||||||
return follow(p->n_follow, p->n_rule);
|
return follow(p->n_follow, p->n_rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC int follow(p_set setp, p_gram p) {
|
static int follow(p_set setp, p_gram p)
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* setp is the follow set for the rule p.
|
* setp is the follow set for the rule p.
|
||||||
* Compute the follow sets in the rule p from this set.
|
* Compute the follow sets in the rule p from this set.
|
||||||
@ -537,11 +574,13 @@ STATIC int follow(p_set setp, p_gram p) {
|
|||||||
|
|
||||||
#ifdef NON_CORRECTING
|
#ifdef NON_CORRECTING
|
||||||
|
|
||||||
STATIC int nc_nfollow(p_nont p) {
|
static int nc_nfollow(p_nont p)
|
||||||
|
{
|
||||||
return follow(p->n_nc_follow, p->n_rule);
|
return follow(p->n_nc_follow, p->n_rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC int nc_follow(p_set setp, p_gram p) {
|
static int nc_follow(p_set setp, p_gram p)
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* setp is the follow set for the rule p.
|
* setp is the follow set for the rule p.
|
||||||
* Compute the follow sets in the rule p from this set.
|
* Compute the follow sets in the rule p from this set.
|
||||||
@ -614,7 +653,8 @@ STATIC int nc_follow(p_set setp, p_gram p) {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
STATIC void co_dirsymb(p_set setp, p_gram p) {
|
static void co_dirsymb(p_set setp, p_gram p)
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* Walk the rule p, doing the work for alternations
|
* Walk the rule p, doing the work for alternations
|
||||||
*/
|
*/
|
||||||
@ -661,7 +701,8 @@ STATIC void co_dirsymb(p_set setp, p_gram p) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC void co_others(p_gram p) {
|
static void co_others(p_gram p)
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* compute the l_others-sets for the list of alternatives
|
* compute the l_others-sets for the list of alternatives
|
||||||
* indicated by p
|
* indicated by p
|
||||||
@ -687,7 +728,7 @@ STATIC void co_others(p_gram p) {
|
|||||||
static p_length length;
|
static p_length length;
|
||||||
# define INFINITY 32767
|
# define INFINITY 32767
|
||||||
|
|
||||||
STATIC int ncomplength(p_nont p)
|
static int ncomplength(p_nont p)
|
||||||
{
|
{
|
||||||
p_length pl = &length[p - nonterms];
|
p_length pl = &length[p - nonterms];
|
||||||
int x = pl->cnt;
|
int x = pl->cnt;
|
||||||
@ -697,7 +738,7 @@ STATIC int ncomplength(p_nont p)
|
|||||||
return pl->cnt < INFINITY && x == INFINITY;
|
return pl->cnt < INFINITY && x == INFINITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC void do_lengthcomp()
|
static void do_lengthcomp()
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Compute the minimum length of a terminal production for each
|
* Compute the minimum length of a terminal production for each
|
||||||
@ -729,7 +770,8 @@ STATIC void do_lengthcomp()
|
|||||||
free ((p_mem) length);
|
free ((p_mem) length);
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC void complength(p_gram p, p_length le) {
|
static void complength(p_gram p, p_length le)
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* Walk grammar rule p, computing minimum lengths
|
* Walk grammar rule p, computing minimum lengths
|
||||||
*/
|
*/
|
||||||
@ -813,7 +855,8 @@ STATIC void complength(p_gram p, p_length le) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC void add(p_length a, int c, int v) {
|
static void add(p_length a, int c, int v)
|
||||||
|
{
|
||||||
if (a->cnt == INFINITY || c == INFINITY) {
|
if (a->cnt == INFINITY || c == INFINITY) {
|
||||||
a->cnt = INFINITY;
|
a->cnt = INFINITY;
|
||||||
return;
|
return;
|
||||||
@ -822,12 +865,14 @@ STATIC void add(p_length a, int c, int v) {
|
|||||||
a->cnt += c;
|
a->cnt += c;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC int compare(p_length a, p_length b) {
|
static int compare(p_length a, p_length b)
|
||||||
|
{
|
||||||
if (a->cnt != b->cnt) return a->cnt - b->cnt;
|
if (a->cnt != b->cnt) return a->cnt - b->cnt;
|
||||||
return a->val - b->val;
|
return a->val - b->val;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC void setdefaults(p_gram p) {
|
static void setdefaults(p_gram p)
|
||||||
|
{
|
||||||
for (;;) {
|
for (;;) {
|
||||||
switch(g_gettype(p)) {
|
switch(g_gettype(p)) {
|
||||||
case EORULE:
|
case EORULE:
|
||||||
@ -868,7 +913,8 @@ STATIC void setdefaults(p_gram p) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC void do_contains(p_nont n) {
|
static void do_contains(p_nont n)
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* Compute the total set of symbols that nonterminal n can
|
* Compute the total set of symbols that nonterminal n can
|
||||||
* produce
|
* produce
|
||||||
@ -895,7 +941,8 @@ STATIC void do_contains(p_nont n) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC void contains(p_gram p, p_set set) {
|
static void contains(p_gram p, p_set set)
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* Does the real computation of the contains-sets
|
* Does the real computation of the contains-sets
|
||||||
*/
|
*/
|
||||||
@ -963,7 +1010,8 @@ STATIC void contains(p_gram p, p_set set) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC int nsafes(p) p_nont p; {
|
static int nsafes(p_nont p)
|
||||||
|
{
|
||||||
int ch;
|
int ch;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -983,8 +1031,8 @@ STATIC int nsafes(p) p_nont p; {
|
|||||||
return ch;
|
return ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC int
|
static int do_safes(p_gram p, int safe, int *ch)
|
||||||
do_safes(p,safe,ch) p_gram p; int *ch; {
|
{
|
||||||
/*
|
/*
|
||||||
* Walk the grammar rule, doing the computation described in the
|
* Walk the grammar rule, doing the computation described in the
|
||||||
* comment of the procedure above this one.
|
* comment of the procedure above this one.
|
||||||
@ -1068,7 +1116,8 @@ do_safes(p,safe,ch) p_gram p; int *ch; {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int t_safety(int rep, int count, int persistent, int safety) {
|
int t_safety(int rep, int count, int persistent, int safety)
|
||||||
|
{
|
||||||
|
|
||||||
if (safety == NOSCANDONE) safety = SCANDONE;
|
if (safety == NOSCANDONE) safety = SCANDONE;
|
||||||
switch(rep) {
|
switch(rep) {
|
||||||
@ -1093,7 +1142,8 @@ int t_safety(int rep, int count, int persistent, int safety) {
|
|||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
|
||||||
int t_after(int rep, int count, int outsafety) {
|
int t_after(int rep, int count, int outsafety)
|
||||||
|
{
|
||||||
if (count == 0 && (rep == STAR || rep == PLUS)) {
|
if (count == 0 && (rep == STAR || rep == PLUS)) {
|
||||||
return SAFESCANDONE;
|
return SAFESCANDONE;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user