regexp.h

Go to the documentation of this file.
00001 /* Eliot                                                                     */
00002 /* Copyright (C) 1999  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   regexp.h
00022  *  \brief  Regular Expression functions
00023  *  \author Antoine Fraboulet
00024  *  \date   2005
00025  */
00026 
00027 #ifndef _TREE_H_
00028 #define _TREE_H_
00029 #if defined(__cplusplus)
00030 extern "C"
00031   {
00032 #endif
00033 
00034 #define NODE_TOP    0
00035 #define NODE_VAR    1
00036 #define NODE_OR     2
00037 #define NODE_AND    3
00038 #define NODE_STAR   4
00039 #define NODE_PLUS   5
00040 
00041 typedef struct node {
00042   int              type;
00043   char             var;
00044   struct node      *fg;
00045   struct node      *fd;
00046   int numero;
00047   int position;
00048   int annulable;
00049   int PP;
00050   int DP;
00051 } NODE;
00052 
00053     /**
00054      * maximum number of accepted terminals in regular expressions
00055      */
00056 #define REGEXP_MAX 32
00057 
00058     /**
00059      * special terminals that should not appear in the dictionary
00060      */
00061 #define RE_EPSILON     (DIC_LETTERS + 0)
00062 #define RE_FINAL_TOK   (DIC_LETTERS + 1)
00063 #define RE_ALL_MATCH   (DIC_LETTERS + 2)
00064 #define RE_VOWL_MATCH  (DIC_LETTERS + 3)
00065 #define RE_CONS_MATCH  (DIC_LETTERS + 4)
00066 #define RE_USR1_MATCH  (DIC_LETTERS + 5)
00067 #define RE_USR2_MATCH  (DIC_LETTERS + 6)
00068 
00069     /**
00070      * number of lists for regexp letter match \n
00071      * 0 : all tiles                           \n
00072      * 1 : vowels                              \n
00073      * 2 : consonants                          \n
00074      * 3 : user defined 1                      \n
00075      * 4 : user defined 2                      \n
00076      * x : lists used during parsing           \n
00077      */
00078 #define DIC_SEARCH_REGE_LIST (REGEXP_MAX)
00079 
00080     /**
00081      * Structure used for Dic_search_RegE \n
00082      * this structure is used to explicit letters list that will be matched
00083      * against special tokens in the regular expression search
00084      */
00085 struct search_RegE_list_t {
00086   /** maximum length for results */
00087   int minlength;
00088   /** maximum length for results */
00089   int maxlength;
00090   /** special symbol associated with the list */
00091   char symbl[DIC_SEARCH_REGE_LIST];
00092   /** 0 or 1 if list is valid */
00093   int  valid[DIC_SEARCH_REGE_LIST];
00094   /** 0 or 1 if letter is present in the list */
00095   char letters[DIC_SEARCH_REGE_LIST][DIC_LETTERS];
00096 };
00097 
00098 #define RE_LIST_ALL_MATCH  0
00099 #define RE_LIST_VOYL_MATCH 1
00100 #define RE_LIST_CONS_MATCH 2
00101 #define RE_LIST_USER_BEGIN 3
00102 #define RE_LIST_USER_END   4
00103 
00104     /**
00105      * Create a node for the syntactic tree used for
00106      * parsing regular expressions                    \n
00107      * The fonction is called by bison grammar rules
00108      */
00109 NODE* regexp_createNODE(int type,char v,NODE *fg,NODE *fd);
00110 
00111     /**
00112      * delete regexp syntactic tree
00113      */
00114 void  regexp_delete_tree(NODE * root);
00115 
00116     /**
00117      * Computes positions, first positions (PP), last position (DP)
00118      * and translation table 'position to letter' (ptl)
00119      * @param p : max position found in the tree (must be initialized to 1)
00120      * @param n : number of nodes in the tree (must be initialized to 1)
00121      * @param ptl : position to letter translation table
00122      */
00123 void  regexp_parcours(NODE* r, int *p, int *n, int ptl[]);
00124 
00125     /**
00126      * Computes 'next position' table used for building the
00127      * automaton
00128      * @param r : root node of the syntactic tree
00129      * @param PS : next position table, PS[0] must contain the
00130      * number of terminals contained in the regular expression
00131      */
00132 void  regexp_possuivante(NODE* r, int PS[]);
00133 
00134 #define MAX_REGEXP_ERROR_LENGTH 500
00135 
00136 struct regexp_error_report_t {
00137   int pos1;
00138   int pos2;
00139   char msg[MAX_REGEXP_ERROR_LENGTH];
00140 };
00141 
00142 #include <stdio.h>
00143 
00144 void  regexp_print_letter(FILE* f, char l);
00145 void  regexp_print_letter2(FILE* f, char l);
00146 void  regexp_print_PS(int PS[]);
00147 void  regexp_print_ptl(int ptl[]);
00148 void  regexp_print_tree(NODE* n, char* name, int detail);
00149 
00150 #if defined(__cplusplus)
00151   }
00152 #endif
00153 #endif /* _TREE_H_ */

Generated on Thu Dec 29 02:01:14 2005 for Eliot by  doxygen 1.4.5