/[eliot]/eliot/dic/automaton.h
ViewVC logotype

Diff of /eliot/dic/automaton.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by afrab, Tue Apr 19 20:18:32 2005 UTC revision 1.6 by afrab, Thu May 5 23:45:04 2005 UTC
# Line 1  Line 1 
1  /* Eliot                                                                     */  /* Eliot                                                                     */
2  /* Copyright (C) 1999  antoine.fraboulet                                     */  /* Copyright (C) 2005  Antoine Fraboulet                                     */
 /* antoine.fraboulet@free.fr                                                 */  
3  /*                                                                           */  /*                                                                           */
4  /* This program is free software; you can redistribute it and/or modify      */  /* This file is part of Eliot.                                               */
5    /*                                                                           */
6    /* Eliot is free software; you can redistribute it and/or modify             */
7  /* it under the terms of the GNU General Public License as published by      */  /* it under the terms of the GNU General Public License as published by      */
8  /* the Free Software Foundation; either version 2 of the License, or         */  /* the Free Software Foundation; either version 2 of the License, or         */
9  /* (at your option) any later version.                                       */  /* (at your option) any later version.                                       */
10  /*                                                                           */  /*                                                                           */
11  /* This program is distributed in the hope that it will be useful,           */  /* Elit is distributed in the hope that it will be useful,                   */
12  /* but WITHOUT ANY WARRANTY; without even the implied warranty of            */  /* but WITHOUT ANY WARRANTY; without even the implied warranty of            */
13  /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             */  /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             */
14  /* GNU General Public License for more details.                              */  /* GNU General Public License for more details.                              */
# Line 15  Line 16 
16  /* You should have received a copy of the GNU General Public License         */  /* You should have received a copy of the GNU General Public License         */
17  /* along with this program; if not, write to the Free Software               */  /* along with this program; if not, write to the Free Software               */
18  /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */  /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
19    
20  /*  /*
21   * $Id$   * $Id$
22   */   */
23    
24    /**
25     *  \file   dic.h
26     *  \brief  Diterministic Finite Automaton
27     *  \author Antoine Fraboulet
28     *  \date   2005
29     */
30    
31  #ifndef _DIC_AUTOMATON_H_  #ifndef _DIC_AUTOMATON_H_
32  #define _DIC_AUTOMATON_H_  #define _DIC_AUTOMATON_H_
33    #if defined(__cplusplus)
34    extern "C"
35      {
36    #endif
37    
38    typedef struct automaton_t       *automaton;
39    
40        /**
41         * build a static deterministic finite automaton from
42         * "init_state", "ptl" and "PS" given by the parser
43         */    
44    automaton automaton_build(int init_state, int *ptl, int *PS, struct search_RegE_list_t *list);
45    
46        /**
47         * automaton delete function
48         */
49    void      automaton_delete         (automaton a);
50    
51        /**
52         * get the number of states in the automaton
53         * @returns number of states
54         */
55    int       automaton_get_nstate     (automaton a);
56    
57        /**
58         * query the id of the init state
59         * @returns init state id
60         */
61    int       automaton_get_init       (automaton a);
62    
63        /**
64         * ask for the acceptor flag for the state
65         * @returns boolean flag 0 or 1
66         */
67    int       automaton_get_accept     (automaton a, int state);
68    
69        /**
70         * returns the next state when the transition is taken
71         * @returns next state id (1 <= id <= nstate, 0 = invalid id)
72         */
73    int       automaton_get_next_state (automaton a, int start, char l);
74    
75    void      automaton_dump           (automaton a, char* filename);
76    
77  struct _automaton {  #if defined(__cplusplus)
78    int nterm;       /* (1 << nterm) == index of maximum state */    }
79    int nstate;      /* number of states                       */  #endif
80    int init;        /* index of initial state                 */  #endif /* _DIC_AUTOMATON_H_ */
   int **Dtrans;    /* Dtrans[state][letter] == next state    */  
   int *accept;     /* accept[state] == 1 -> accept state     */  
   int *marque;     /* marque[state] == 1 -> valid state      */  
   int callocsize;  /* keep track of allocated size */  
 };  
   
 typedef struct _automaton* automaton;  
   
 automaton automaton_build (int init_state, int *ptl, int *PS);  
 void      automaton_delete(automaton a);  
   
 #ifdef DEBUG_RE  
 void      automaton_dump  (automaton a, char* filename);  
 #endif  
 #endif  

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26