1991-11-23 10:41:43 +00:00
|
|
|
/* Copyright (c) 1991 by the Vrije Universiteit, Amsterdam, the Netherlands.
|
1995-07-31 09:17:14 +00:00
|
|
|
* For full copyright and restrictions on use see the file COPYING in the top
|
1995-07-31 09:10:42 +00:00
|
|
|
* level of the LLgen tree.
|
1984-10-08 14:14:53 +00:00
|
|
|
*/
|
2019-02-18 16:39:05 +00:00
|
|
|
#ifndef SETS_H_
|
|
|
|
#define SETS_H_
|
1984-10-08 14:14:53 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* L L G E N
|
|
|
|
*
|
|
|
|
* An Extended LL(1) Parser Generator
|
|
|
|
*
|
|
|
|
* Author : Ceriel J.H. Jacobs
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
1994-06-24 11:31:16 +00:00
|
|
|
* $Id$
|
1984-10-08 14:14:53 +00:00
|
|
|
* Some macros that deal with bitsets and their size
|
|
|
|
*/
|
|
|
|
|
|
|
|
# define BITS (8 * sizeof (int))
|
|
|
|
# define IN(a,i) ((a)[(i)/BITS] & (1<<((i) % BITS)))
|
1985-11-25 15:47:51 +00:00
|
|
|
# define NTIN(a,i) ((a)[(i)/BITS+tsetsize]&(1<<((i)%BITS)))
|
1984-10-08 14:14:53 +00:00
|
|
|
# define PUTIN(a,i) ((a)[(i)/BITS] |=(1<<((i) % BITS)))
|
1985-11-25 15:47:51 +00:00
|
|
|
# define NTPUTIN(a,i) ((a)[(i)/BITS+tsetsize]|=(1<<((i)%BITS)))
|
1984-10-08 14:14:53 +00:00
|
|
|
# define NBYTES(n) (((n) + 7) / 8)
|
|
|
|
/*
|
|
|
|
* The next two macros operate on byte counts!
|
|
|
|
*/
|
|
|
|
# define NINTS(n) (((n) + (int) (sizeof(int) - 1)) / (int) sizeof(int))
|
|
|
|
# define ALIGN(n) (NINTS(n) * (int) sizeof (int))
|
|
|
|
|
1985-11-25 15:47:51 +00:00
|
|
|
extern int tsetsize;
|
|
|
|
extern p_set *setptr, *maxptr;
|
|
|
|
extern int nbytes;
|
2019-02-18 16:39:05 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialises some variables needed for setcomputations
|
|
|
|
*/
|
|
|
|
void setinit(int nt_needed);
|
|
|
|
/*
|
|
|
|
* Allocate a set that cannot be freed
|
|
|
|
*/
|
|
|
|
p_set get_set(void);
|
|
|
|
/*
|
|
|
|
* Allocate a set which can later be freed.
|
|
|
|
*/
|
|
|
|
p_set setalloc(void);
|
|
|
|
/*
|
|
|
|
* a = a union b.
|
|
|
|
* Return 1 if the set a changed
|
|
|
|
*/
|
|
|
|
int setunion(register p_set a,register p_set b);
|
|
|
|
/*
|
|
|
|
* a = a intersect b.
|
|
|
|
* return 1 if the result is empty
|
|
|
|
*/
|
|
|
|
int setintersect(register p_set a,register p_set b);
|
|
|
|
/*
|
|
|
|
* a = a setminus b
|
|
|
|
*/
|
|
|
|
void setminus(register p_set a,register p_set b);
|
|
|
|
/*
|
|
|
|
* Return 1 if the set p is empty
|
|
|
|
*/
|
|
|
|
int setempty(register p_set p);
|
|
|
|
/*
|
|
|
|
* The set "set" will serve as a recovery set.
|
|
|
|
* Search for it in the table. If not present, enter it.
|
|
|
|
* Here is room for improvement. At the moment, the list of
|
|
|
|
* sets is examined with linear search.
|
|
|
|
*/
|
|
|
|
int findindex(p_set set);
|
|
|
|
int setcount(register p_set set, int *saved);
|
|
|
|
|
|
|
|
#endif /* SETS_H_ */
|