/*
 * Copyright 1990 by Baylor College of Medicine ALL RIGHTS RESERVED. 
 *
 * This program is subject to a license agreement between 
 * Baylor College of Medicine and MIT. Any use inconsistent with
 * said license and any use by persons other than the faculty, 
 * students and staff at MIT or any use on a computer not operated 
 * as part of the Athena Computing Environment (ACE) is expressly 
 * prohibited.
 */
#ifndef __DFA__
#define __DFA__

typedef struct
{
	int *lst ;
	int n ;
} Int_List ;

/*
 *	A state has transitions to other states and can be a final (accepting) state.
 */
typedef struct
{
	Int_List labels ;
	int is_final ;
	int transitions[256] ;
} State ;

/*
 *	A dfa is a collection of states and a start state.  (Ascii is assumed).
 */
typedef struct
{
	int label ;
	State *states ;
	int n_states ;
	int start_state ;
} *Dfa ;

Dfa dfa_concat() ;
Dfa dfa_set_op() ;
Dfa dfa_closure() ;
Dfa dfa_pclosure() ;
Dfa dfa_string() ;
Dfa dfa_nstring() ;
Dfa dfa_wild_string() ;
Dfa dfa_wild_nchar() ;
Dfa dfa_compl() ;
Dfa dfa_zero() ;
Dfa dfa_pattern_string() ;
Dfa dfa_zero() ;
int dfa_execute() ;

#define dfa_union(lab,d1,d2) dfa_set_op(lab,d1,d2,(unsigned long)14)
#define dfa_inter(lab,d1,d2) dfa_set_op(lab,d1,d2,(unsigned long)8)
#define dfa_subtract(lab,d1,d2) dfa_set_op(lab,d1,d2,(unsigned long)4)

#endif
