00001 /* Eliot */ 00002 /* Copyright (C) 2005 Antoine Fraboulet */ 00003 /* */ 00004 /* This file is part of Eliot. */ 00005 /* */ 00006 /* Eliot is free software; you can redistribute it and/or modify */ 00007 /* it under the terms of the GNU General Public License as published by */ 00008 /* the Free Software Foundation; either version 2 of the License, or */ 00009 /* (at your option) any later version. */ 00010 /* */ 00011 /* Eliot is distributed in the hope that it will be useful, */ 00012 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 00013 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ 00014 /* GNU General Public License for more details. */ 00015 /* */ 00016 /* You should have received a copy of the GNU General Public License */ 00017 /* along with this program; if not, write to the Free Software */ 00018 /* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 00019 00020 /** 00021 * \file automaton.h 00022 * \brief (Non)Deterministic Finite Automaton for Regexp 00023 * \author Antoine Fraboulet 00024 * \date 2005 00025 */ 00026 00027 #ifndef _DIC_AUTOMATON_H_ 00028 #define _DIC_AUTOMATON_H_ 00029 #if defined(__cplusplus) 00030 extern "C" 00031 { 00032 #endif 00033 00034 typedef struct automaton_t *automaton; 00035 00036 /** 00037 * build a static deterministic finite automaton from 00038 * "init_state", "ptl" and "PS" given by the parser 00039 */ 00040 automaton automaton_build(int init_state, int *ptl, int *PS, struct search_RegE_list_t *list); 00041 00042 /** 00043 * automaton delete function 00044 */ 00045 void automaton_delete (automaton a); 00046 00047 /** 00048 * get the number of states in the automaton 00049 * @returns number of states 00050 */ 00051 int automaton_get_nstate (automaton a); 00052 00053 /** 00054 * query the id of the init state 00055 * @returns init state id 00056 */ 00057 int automaton_get_init (automaton a); 00058 00059 /** 00060 * ask for the acceptor flag for the state 00061 * @returns boolean flag 0 or 1 00062 */ 00063 int automaton_get_accept (automaton a, int state); 00064 00065 /** 00066 * returns the next state when the transition is taken 00067 * @returns next state id (1 <= id <= nstate, 0 = invalid id) 00068 */ 00069 int automaton_get_next_state (automaton a, int start, char l); 00070 00071 void automaton_dump (automaton a, char* filename); 00072 00073 #if defined(__cplusplus) 00074 } 00075 #endif 00076 #endif /* _DIC_AUTOMATON_H_ */