Tizen 2.0 Release
[external/mawk.git] / rexp / rexpdb.c
1
2 /********************************************
3 rexpdb.c
4 copyright 1991, Michael D. Brennan
5
6 This is a source file for mawk, an implementation of
7 the AWK programming language.
8
9 Mawk is distributed without warranty under the terms of
10 the GNU General Public License, version 2, 1991.
11 ********************************************/
12
13
14 /*$Log: rexpdb.c,v $
15  * Revision 1.2  1993/07/23  13:21:51  mike
16  * cleanup rexp code
17  *
18  * Revision 1.1.1.1  1993/07/03  18:58:28  mike
19  * move source to cvs
20  *
21  * Revision 3.2  1991/08/13  09:10:09  brennan
22  * VERSION .9994
23  *
24  * Revision 3.1  91/06/07  10:33:30  brennan
25  * VERSION 0.995
26  * 
27 */
28
29
30 #include "rexp.h"
31 #include <ctype.h>
32
33 /*  print a machine for debugging  */
34
35 static  char *xlat[] = {
36 "M_STR"  ,
37 "M_CLASS" ,
38 "M_ANY" ,
39 "M_START" ,
40 "M_END" ,
41 "M_U",
42 "M_1J" ,
43 "M_2JA" ,
44 "M_2JB" ,
45 "M_ACCEPT" } ;
46
47 void  REmprint(m, f)
48   PTR  m ; 
49   FILE *f ;
50 { register STATE *p = (STATE *) m ;
51   char *end_on_string ;
52
53   while ( 1 )
54   { 
55     if ( p->type >= END_ON ) 
56     { p->type -= END_ON ; end_on_string = "$" ; }
57     else end_on_string = "" ;
58
59     if ( p->type < 0 || p->type >= END_ON )
60     { fprintf(f, "unknown STATE type\n") ; return ; }
61
62     fprintf(f, "%-10s" , xlat[p->type]) ;
63     switch( p->type )
64     {
65      case M_STR : fprintf(f, "%s", p->data.str ) ;
66                   break ;
67
68      case M_1J:
69      case M_2JA:  
70      case M_2JB : fprintf(f, "%d", p->data.jump) ;
71                  break ;
72      case M_CLASS:
73           { unsigned char *q = (unsigned char *) p->data.bvp ;
74             unsigned char *r = q +  sizeof(BV) ;
75             while ( q < r )  fprintf(f, "%x " , *q++) ;
76           }
77           break ;
78     }
79     fprintf(f, "%s\n" , end_on_string) ;
80     if ( end_on_string[0] )  p->type += END_ON ;
81     if ( p->type == M_ACCEPT )  return ;
82     p++ ;
83    }
84 }
85