Pristine Ack-5.5
[Ack-5.5.git] / h / cg_pattern.h
1 /* $Id: cg_pattern.h,v 1.5 1994/06/24 10:08:01 ceriel Exp $ */
2 /*
3  * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
4  * See the copyright notice in the ACK home directory, in the file "Copyright".
5  */
6 /* offsets of interesting fields in EM-pattern */
7
8 #define PO_HASH         0
9 #define PO_NEXT         1
10 #define PO_MATCH        3
11
12 #define ILLHASH 0177777
13
14 /* Escapes in printstrings */
15
16 #define PR_TOK          '\001'
17 #define PR_TOKFLD       '\002'
18 #define PR_EMINT        '\003'
19 #define PR_EMSTR        '\004'
20 #define PR_ALLREG       '\005'
21 #define PR_SUBREG       '\006'
22 /*
23  * In case this list gets longer remember to keep out printable nonprintables
24  * like \t \n \r and the like.
25  */
26
27 /* Commands for codegenerator, in low order 5 bits of byte */
28
29 #define DO_NEXTEM       0
30 #define DO_MATCH        1
31 #define DO_XMATCH       2
32 #define DO_XXMATCH      3
33 #define DO_REMOVE       4
34 #define DO_DEALLOCATE   5
35 #define DO_REALLOCATE   6
36 #define DO_ALLOCATE     7
37 #define DO_LOUTPUT      8
38 #define DO_ROUTPUT      9
39 #define DO_MOVE         10
40 #define DO_ERASE        11
41 #define DO_TOKREPLACE   12
42 #define DO_EMREPLACE    13
43 #define DO_COST         14
44 #define DO_RETURN       15
45 #define DO_COERC        16
46 #define DO_PRETURN      17
47 #define DO_RREMOVE      18
48
49 typedef struct instance {
50         int in_which;
51 #               define IN_COPY          1
52 #               define IN_RIDENT        2
53 #               define IN_ALLOC         3
54 #               define IN_DESCR         4
55 #               define IN_REGVAR        5
56         int in_info[TOKENSIZE+1];
57 } inst_t,*inst_p;
58
59 typedef struct {
60         int     c_size;                 /* index in enode-table */
61         int     c_time;                 /* dito */
62 } cost_t,*cost_p;
63
64 typedef struct {
65         int m_set1;             /* number of tokenexpr in move: from */
66         int m_expr1;            /* optional expression */
67         int m_set2;             /* number of tokenexpr in move: to */
68         int m_expr2;            /* optional expression */
69         int m_cindex;           /* code index to really do it */
70         cost_t m_cost;          /* associated cost */
71 } move_t, *move_p;
72
73 typedef struct {
74         int set_size;
75         short set_val[SETSIZE];
76 } set_t,*set_p;
77
78 struct exprnode {
79         short ex_operator;
80         short ex_lnode;
81         short ex_rnode;
82 };
83 typedef struct exprnode node_t;
84 typedef struct exprnode *node_p;
85
86 typedef struct {        /* to stack coercions */
87         int c1_texpno;          /* token expression number */
88         int c1_expr;            /* boolean expression */
89         int c1_prop;            /* property of register needed */
90         int c1_codep;           /* code index */
91         cost_t c1_cost;         /* cost involved */
92 } c1_t,*c1_p;
93
94 #ifdef MAXSPLIT
95 typedef struct {        /* splitting coercions */
96         int c2_texpno;          /* token expression number */
97         int c2_nsplit;          /* split factor */
98         int c2_repl[MAXSPLIT];  /* replacement instances */
99         int c2_codep;           /* code index */
100 } c2_t,*c2_p;
101 #endif /* MAXSPLIT */
102
103 typedef struct {        /* one to one coercions */
104         int c3_texpno;          /* token expression number */
105         int c3_prop;            /* property of register needed */
106         int c3_repl;            /* replacement instance */
107         int c3_codep;           /* code index */
108 } c3_t,*c3_p;
109
110 /*
111  * contents of .ex_operator
112  */
113
114 #define EX_TOKFIELD     0
115 #define EX_ARG          1
116 #define EX_CON          2
117 #define EX_ALLREG       3
118 #define EX_SAMESIGN     4
119 #define EX_SFIT         5
120 #define EX_UFIT         6
121 #define EX_ROM          7
122 #define EX_NCPEQ        8
123 #define EX_SCPEQ        9
124 #define EX_RCPEQ        10
125 #define EX_NCPNE        11
126 #define EX_SCPNE        12
127 #define EX_RCPNE        13
128 #define EX_NCPGT        14
129 #define EX_NCPGE        15
130 #define EX_NCPLT        16
131 #define EX_NCPLE        17
132 #define EX_OR2          18
133 #define EX_AND2         19
134 #define EX_PLUS         20
135 #define EX_CAT          21
136 #define EX_MINUS        22
137 #define EX_TIMES        23
138 #define EX_DIVIDE       24
139 #define EX_MOD          25
140 #define EX_LSHIFT       26
141 #define EX_RSHIFT       27
142 #define EX_NOT          28
143 #define EX_COMP         29
144 #define EX_COST         30
145 #define EX_STRING       31
146 #define EX_DEFINED      32
147 #define EX_SUBREG       33
148 #define EX_TOSTRING     34
149 #define EX_UMINUS       35
150 #define EX_REG          36
151 #define EX_LOWW         37
152 #define EX_HIGHW        38
153 #define EX_INREG        39
154 #define EX_REGVAR       40
155
156
157
158 #define getint(a,b) \
159         if ((a=((*(b)++)&BMASK)) >= 128) {\
160                 a = ((a-128)<<BSHIFT) | (*(b)++&BMASK); \
161         }