// The classes Conf, LConf and ConfSet allow for the representation of a
// configuration, configuration with a lookahead, and a configuration
// set.  The classes ConfList, LConfList and ConfSetList allow for lists
// of corresponding items.

class Conf;

class ConfList : public list<Conf *> {
public:
	Conf *find(ParNode *);
};

// The configuration A -> B . C D is represented by a rule pointer to A,
// and a dot pointer to C.  While the former is not totally necessary,
// it is present to prevent repeated computation.

class Conf {
public:
	static ConfList confs;
	int id;
	ParRule *rule;
	ParNode *dot;
	void show(FILE *);
	Conf(ParRule *r, ParNode *d) {
		rule = r; dot = d;
		Conf *item = this; confs.append(item);
	}
};

class LConf;

class LConfList : public list<LConf *> {
public:
	LConf *find(Conf *);
	void replicate();
	void append(const LConf *i);
};

// A lookahead configuration consist of a pointer to the actual
// configuration and a lookahead set.

class LConf {
public:
	static LConfList cogs;
	Conf *conf;
	void show(FILE *);
	list<ParRule *> lookAhead;
	LConf(Conf *c) {
		conf = c;
		LConf *item = this;
		cogs.append(item);
	}
};

// Finally, a configuration set is represented as a sequence of
// lookahead configurations.  A transition from a configuration set to
// another is represented by a Move.

class ConfSet;
class Move;

class MoveList : public list<Move *> {
public:
	ConfSet *findDest(ParRule *);
};

// A Move instance is represented by the symbol causing the transition
// and the destination state.

class Move {
public:
	ParRule *trigger;
	ConfSet *dest;
	void show(FILE *);
	Move(ParRule *r, ConfSet *d) { trigger = r; dest = d; }
};

class ConfSetList : public list<ConfSet *> {
public:
	ConfSet *find(LConfList *);
};

// A configuration set is represented by the closure set and the list of
// possible moves.

class ConfSet {
	int _id;
public:
	static ConfSetList confSets;
	static int NextId;
	int id() { return _id; }
	LConfList *closure;
	MoveList moves;
	ConfSet *destOf(ParRule *r) { return(moves.findDest(r)); }
	void findMoves();
	void show(FILE *);
	ConfSet(LConfList *c) {
		_id = NextId++; closure = c;
		ConfSet *item = this;
		confSets.append(item);
	}
};


syntax highlighted by Code2HTML, v. 0.9.1