1 /***********************************************************************
2 *                                                                      *
3 *               This software is part of the ast package               *
4 *          Copyright (c) 1984-2011 AT&T Intellectual Property          *
5 *                      and is licensed under the                       *
6 *                 Eclipse Public License, Version 1.0                  *
7 *                    by AT&T Intellectual Property                     *
8 *                                                                      *
9 *                A copy of the License is available at                 *
10 *          http://www.eclipse.org/org/documents/epl-v10.html           *
11 *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         *
12 *                                                                      *
13 *              Information and Software Systems Research               *
14 *                            AT&T Research                             *
15 *                           Florham Park NJ                            *
16 *                                                                      *
17 *                 Glenn Fowler <gsf@research.att.com>                  *
18 *                                                                      *
19 ***********************************************************************/
20 #pragma prototyped
21 /*
22  * Glenn Fowler
23  * AT&T Research
24  *
25  * make variable expansion long name interface and data
26  * in a header to allow an external old->new syntax converter
27  *
28  * edit op names are mapped to the interpreted <op><sep><arg> forms
29  */
30 
31 #ifndef ED_EDIT
32 
33 typedef struct
34 {
35 	unsigned short		type;		/* {ED_OP,ED_QUAL}	*/
36 	unsigned short		op;		/* old op name letter	*/
37 	unsigned short		arg;		/* old op value char 1	*/
38 	unsigned short		aux;		/* old op value char 2	*/
39 } Edit_cmd_t;
40 
41 typedef struct
42 {
43 	const char*		name;		/* option name		*/
44 	const Edit_cmd_t	cmd;		/* cmd info		*/
45 } Edit_opt_t;
46 
47 typedef struct
48 {
49 	const char*		name;		/* operator name	*/
50 	const Edit_opt_t*	options;	/* operator option map	*/
51 	const Edit_cmd_t	cmd;		/* cmd info		*/
52 } Edit_map_t;
53 
54 typedef struct
55 {
56 	const char*		old;		/* old op		*/
57 	const char*		xxx;		/* new op		*/
58 	int			len;		/* len(old)==len(xxx)	*/
59 } Edit_xxx_t;
60 
61 #define LT		(1<<0)
62 #define EQ		(1<<1)
63 #define GT		(1<<2)
64 #define NOT		(1<<3)
65 #define HAT		(1<<4)
66 #define MAT		(1<<5)
67 
68 #define NE		(NOT|EQ)
69 #define LE		(LT|EQ)
70 #define GE		(GT|EQ)
71 #define CMP		(1<<6)
72 
73 #define ED_COPY		1
74 #define ED_EDIT		2
75 #define ED_OP		3
76 #define ED_QUAL		4
77 
78 #define ED_AUXILLIARY	(CMP<<0)
79 #define ED_FORCE	(CMP<<1)
80 #define ED_JOIN		(CMP<<5)
81 #define ED_LITERAL	(CMP<<2)
82 #define ED_LONG		(CMP<<3)
83 #define ED_NOBIND	(CMP<<4)
84 #define ED_NOWAIT	(CMP<<6)
85 #define ED_PARTS	(CMP<<7)
86 #define ED_PRIMARY	(CMP<<8)
87 
88 /*
89  * old -> new ops not captured by the tables
90  */
91 
92 static const Edit_xxx_t		editxxx[] =
93 {
94 	"A>",		"N>",		2,
95 	0
96 };
97 
98 static const Edit_opt_t		editbind[] =
99 {
100 	"force",		{ ED_QUAL,ED_FORCE	},
101 	"nowait",		{ ED_QUAL,ED_NOWAIT	},
102 	0
103 };
104 
105 static const Edit_opt_t		editbound[] =
106 {
107 	"",			{ ED_OP,   0,'B'	},
108 	"directory",		{ ED_OP,   0,'D'	},
109 	0
110 };
111 
112 static const Edit_opt_t		editgenerate[] =
113 {
114 	"target",		{ ED_QUAL,LT		},
115 	0
116 };
117 
118 static const Edit_opt_t		editintersect[] =
119 {
120 	"literal",		{ ED_QUAL,LT		},
121 	0
122 };
123 
124 static const Edit_opt_t		editlist[] =
125 {
126 	"",			{ ED_QUAL,EQ		},
127 	"first",		{ ED_QUAL,EQ		},
128 	"sort",			{ ED_QUAL,LT		},
129 	"reverse",		{ ED_QUAL,GT		},
130 	0
131 };
132 
133 static const Edit_opt_t		editmatch[] =
134 {
135 	"prereqs",		{ ED_QUAL,GT		},
136 	"re",			{ ED_OP,   'M'		},
137 	0
138 };
139 
140 static const Edit_opt_t		editread[] =
141 {
142 	"raw",			{ ED_OP,   0,'X'	},
143 	0
144 };
145 
146 static const Edit_opt_t		editsort[] =
147 {
148 	"numeric",		{ ED_QUAL,EQ		},
149 	"reverse",		{ ED_QUAL,GT		},
150 	"unique",		{ ED_QUAL,NOT		},
151 	0
152 };
153 
154 static const Edit_opt_t		editstate[] =
155 {
156 	"",			{ ED_OP,   0,'S'	},
157 	"assign",		{ ED_OP,   0,'E'	},
158 	"define",		{ ED_OP,   0,'D'	},
159 	"prereqs",		{ ED_OP,   0,'S','P'	},
160 	"rule",			{ ED_OP,   0,'S','R'	},
161 	"variable",		{ ED_OP,   0,'S','V'	},
162 	0
163 };
164 
165 static const Edit_opt_t		edittime[] =
166 {
167 	"event",		{ ED_OP,   0,'E'	},
168 	"prereqs",		{ ED_OP,   0,'C'	},
169 	"rule",			{ ED_OP,   0,'R'	},
170 	"state",		{ ED_OP,   0,'S'	},
171 	"wall",			{ ED_OP,   0,'W'	},
172 	0
173 };
174 
175 static const Edit_opt_t		editview[] =
176 {
177 	"",			{ ED_OP,   0,'L'	},
178 	"all",			{ ED_OP,   0,'L','*'	},
179 	"subdirectory",		{ ED_OP,   0,'S'	},
180 	"top",			{ ED_OP,   0,'L','!'	},
181 	0
182 };
183 
184 static const Edit_opt_t		editwrite[] =
185 {
186 	"append",		{ ED_OP,   0,'A'	},
187 	"numeric",		{ ED_OP,   0,'N'	},
188 	"raw",			{ ED_OP,   0,'X'	},
189 	0
190 };
191 
192 static const Edit_map_t		editmap[] =
193 {
194 	"absolute",		0,		{ ED_OP,  'P','A'	},
195 	"access",		0,		{ ED_OP,  'P','X'	},
196 	"alias",		0,		{ ED_OP,  'P','Z'	},
197 	"archive_update",	0,		{ ED_OP,  'T','A'	},
198 	"associate",		0,		{ ED_OP,  'A','<'	},
199 	"attribute",		0,		{ ED_OP,  'A'		},
200 	"base",			0,		{ ED_EDIT,'B',1		},
201 	"bind",			0,		{ ED_OP,  'T','*'	},
202 	"bound",		editbound,	{ ED_OP,  'P'		},
203 	"break",		0,		{ ED_OP,  'K'		},
204 	"canon",		0,		{ ED_OP,  'P','C'	},
205 	"cross",		0,		{ ED_OP,  'X'		},
206 	"directory",		0,		{ ED_EDIT,'D',1		},
207 	"expr",			0,		{ ED_COPY,'E'		},
208 	"format",		0,		{ ED_OP,  'F'		},
209 	"generate",		editgenerate,	{ ED_OP,  'G'		},
210 	"generated",		0,		{ ED_OP,  'T','G'	},
211 	"hash",			0,		{ ED_OP,  'P','H'	},
212 	"id",			0,		{ ED_OP,  'P','I'	},
213 	"index",		0,		{ ED_OP,  'O'		},
214 	"intersect",		editintersect,	{ ED_OP,  'I'		},
215 	"isrule",		0,		{ ED_OP,  'T','Q'	},
216 	"isvariable",		0,		{ ED_OP,  'T','Q','V'	},
217 	"join",			0,		{ ED_QUAL,ED_JOIN	},
218 	"list",			editlist,	{ ED_OP,  'L'		},
219 	"match",		editmatch,	{ ED_OP,  'N'		},
220 	"metarule",		0,		{ ED_OP,  'T','S','M'	},
221 	"native",		0,		{ ED_OP,  'P','N'	},
222 	"nobase",		0,		{ ED_EDIT,'B',0		},
223 	"nodirectory",		0,		{ ED_EDIT,'D',0		},
224 	"nosuffix",		0,		{ ED_EDIT,'S',0		},
225 	"not",			0,		{ ED_QUAL,NOT		},
226 	"parentage",		0,		{ ED_OP,  'T','M'	},
227 	"parse",		0,		{ ED_OP,  'R'		},
228 	"physical",		0,		{ ED_OP,  'T','P'	},
229 	"probe",		0,		{ ED_OP,  'P','P'	},
230 	"quote",		0,		{ ED_OP,  'Q'		},
231 	"read",			editread,	{ ED_OP,  'T','I'	},
232 	"relative",		0,		{ ED_OP,  'P','R'	},
233 	"rule",			0,		{ ED_OP,  'T','S','A'	},
234 	"sort",			editsort,	{ ED_OP,  'H'		},
235 	"state",		editstate,	{ ED_OP,  'T'		},
236 	"substitute",		0,		{ ED_COPY,'C'		},
237 	"suffix",		0,		{ ED_EDIT,'S',1		},
238 	"test",			0,		{ ED_COPY,'Y'		},
239 	"time",			edittime,	{ ED_OP,  'T','Z'	},
240 	"timecmp",		0,		{ ED_OP,  'T'		},
241 	"unbound",		0,		{ ED_OP,  'P','U'	},
242 	"unstate",		0,		{ ED_OP,  'T','U'	},
243 	"view",			editview,	{ ED_OP,  'P'		},
244 	"write",		editwrite,	{ ED_OP,  'T','O'	},
245 };
246 
247 #endif
248