1 |
|
|
#include <stdlib.h> |
2 |
|
|
#include <string.h> |
3 |
|
|
#define YYBYACC 1 |
4 |
|
|
#define YYMAJOR 1 |
5 |
|
|
#define YYMINOR 9 |
6 |
|
|
#define YYLEX yylex() |
7 |
|
|
#define YYEMPTY -1 |
8 |
|
|
#define yyclearin (yychar=(YYEMPTY)) |
9 |
|
|
#define yyerrok (yyerrflag=0) |
10 |
|
|
#define YYRECOVERING() (yyerrflag!=0) |
11 |
|
|
#define YYPREFIX "yy" |
12 |
|
|
#line 50 "map_parse.y" |
13 |
|
|
|
14 |
|
|
#include <sys/time.h> |
15 |
|
|
#include <dev/wscons/wsksymdef.h> |
16 |
|
|
#include <dev/wscons/wsconsio.h> |
17 |
|
|
#include <err.h> |
18 |
|
|
#include "wsconsctl.h" |
19 |
|
|
|
20 |
|
|
extern struct wskbd_map_data kbmap; /* from keyboard.c */ |
21 |
|
|
|
22 |
|
|
static struct wscons_keymap mapdata[KS_NUMKEYCODES]; |
23 |
|
|
struct wskbd_map_data newkbmap; /* used in util.c */ |
24 |
|
|
static struct wscons_keymap *cur_mp; |
25 |
|
|
|
26 |
|
|
static int ksym_lookup(keysym_t); |
27 |
|
|
|
28 |
|
|
static int |
29 |
|
|
ksym_lookup(keysym_t ksym) |
30 |
|
|
{ |
31 |
|
|
int i; |
32 |
|
|
struct wscons_keymap *mp; |
33 |
|
|
|
34 |
|
|
for (i = 0; i < kbmap.maplen; i++) { |
35 |
|
|
mp = kbmap.map + i; |
36 |
|
|
if (mp->command == ksym || |
37 |
|
|
mp->group1[0] == ksym || mp->group1[1] == ksym || |
38 |
|
|
mp->group2[0] == ksym || mp->group2[1] == ksym) |
39 |
|
|
return(i); |
40 |
|
|
} |
41 |
|
|
|
42 |
|
|
errx(1, "keysym %s not found", ksym2name(ksym)); |
43 |
|
|
} |
44 |
|
|
|
45 |
|
|
#line 84 "map_parse.y" |
46 |
|
|
#ifndef YYSTYPE_DEFINED |
47 |
|
|
#define YYSTYPE_DEFINED |
48 |
|
|
typedef union { |
49 |
|
|
keysym_t kval; |
50 |
|
|
int ival; |
51 |
|
|
} YYSTYPE; |
52 |
|
|
#endif /* YYSTYPE_DEFINED */ |
53 |
|
|
#line 54 "map_parse.c" |
54 |
|
|
#define T_KEYSYM 257 |
55 |
|
|
#define T_KEYCODE 258 |
56 |
|
|
#define T_KEYSYM_VAR 259 |
57 |
|
|
#define T_KEYSYM_CMD_VAR 260 |
58 |
|
|
#define T_NUMBER 261 |
59 |
|
|
#define YYERRCODE 256 |
60 |
|
|
const short yylhs[] = |
61 |
|
|
{ -1, |
62 |
|
|
3, 0, 2, 2, 4, 4, 5, 8, 6, 7, |
63 |
|
|
7, 9, 9, 9, 9, 1, 1, |
64 |
|
|
}; |
65 |
|
|
const short yylen[] = |
66 |
|
|
{ 2, |
67 |
|
|
0, 2, 1, 2, 1, 1, 4, 0, 6, 0, |
68 |
|
|
1, 1, 2, 3, 4, 1, 1, |
69 |
|
|
}; |
70 |
|
|
const short yydefred[] = |
71 |
|
|
{ 1, |
72 |
|
|
0, 0, 0, 0, 0, 3, 5, 6, 16, 17, |
73 |
|
|
0, 0, 4, 0, 8, 7, 0, 11, 0, 0, |
74 |
|
|
9, 0, 0, 15, |
75 |
|
|
}; |
76 |
|
|
const short yydgoto[] = |
77 |
|
|
{ 1, |
78 |
|
|
11, 5, 2, 6, 7, 8, 19, 17, 21, |
79 |
|
|
}; |
80 |
|
|
const short yysindex[] = |
81 |
|
|
{ 0, |
82 |
|
|
0, -242, -255, -261, -242, 0, 0, 0, 0, 0, |
83 |
|
|
-52, -48, 0, -255, 0, 0, -243, 0, -255, -255, |
84 |
|
|
0, -255, -255, 0,}; |
85 |
|
|
const short yyrindex[] = |
86 |
|
|
{ 0, |
87 |
|
|
0, 0, 0, 0, 18, 0, 0, 0, 0, 0, |
88 |
|
|
0, 0, 0, 0, 0, 0, -247, 0, 0, 1, |
89 |
|
|
0, 3, 5, 0,}; |
90 |
|
|
const short yygindex[] = |
91 |
|
|
{ 0, |
92 |
|
|
-12, 0, 0, 14, 0, 0, 0, 0, 0, |
93 |
|
|
}; |
94 |
|
|
#define YYTABLESIZE 263 |
95 |
|
|
const short yytable[] = |
96 |
|
|
{ 12, |
97 |
|
|
12, 16, 13, 9, 14, 10, 20, 22, 14, 23, |
98 |
|
|
24, 10, 15, 10, 3, 4, 18, 2, 13, 0, |
99 |
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
100 |
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
101 |
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
102 |
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
103 |
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
104 |
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
105 |
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
106 |
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
107 |
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
108 |
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
109 |
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
110 |
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
111 |
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
112 |
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
113 |
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
114 |
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
115 |
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
116 |
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
117 |
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
118 |
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
119 |
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
120 |
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
121 |
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
122 |
|
|
0, 0, 0, 0, 0, 0, 0, 12, 12, 13, |
123 |
|
|
13, 14, 14, |
124 |
|
|
}; |
125 |
|
|
const short yycheck[] = |
126 |
|
|
{ 261, |
127 |
|
|
0, 14, 0, 259, 0, 261, 19, 20, 61, 22, |
128 |
|
|
23, 259, 61, 261, 257, 258, 260, 0, 5, -1, |
129 |
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
130 |
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
131 |
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
132 |
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
133 |
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
134 |
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
135 |
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
136 |
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
137 |
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
138 |
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
139 |
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
140 |
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
141 |
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
142 |
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
143 |
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
144 |
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
145 |
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
146 |
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
147 |
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
148 |
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
149 |
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
150 |
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
151 |
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
152 |
|
|
-1, -1, -1, -1, -1, -1, -1, 257, 258, 257, |
153 |
|
|
258, 257, 258, |
154 |
|
|
}; |
155 |
|
|
#define YYFINAL 1 |
156 |
|
|
#ifndef YYDEBUG |
157 |
|
|
#define YYDEBUG 0 |
158 |
|
|
#endif |
159 |
|
|
#define YYMAXTOKEN 261 |
160 |
|
|
#if YYDEBUG |
161 |
|
|
const char * const yyname[] = |
162 |
|
|
{ |
163 |
|
|
"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
164 |
|
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0, |
165 |
|
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
166 |
|
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
167 |
|
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
168 |
|
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
169 |
|
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"T_KEYSYM","T_KEYCODE", |
170 |
|
|
"T_KEYSYM_VAR","T_KEYSYM_CMD_VAR","T_NUMBER", |
171 |
|
|
}; |
172 |
|
|
const char * const yyrule[] = |
173 |
|
|
{"$accept : program", |
174 |
|
|
"$$1 :", |
175 |
|
|
"program : $$1 expr_list", |
176 |
|
|
"expr_list : expr", |
177 |
|
|
"expr_list : expr_list expr", |
178 |
|
|
"expr : keysym_expr", |
179 |
|
|
"expr : keycode_expr", |
180 |
|
|
"keysym_expr : T_KEYSYM keysym_var '=' keysym_var", |
181 |
|
|
"$$2 :", |
182 |
|
|
"keycode_expr : T_KEYCODE T_NUMBER '=' $$2 keysym_cmd keysym_list", |
183 |
|
|
"keysym_cmd :", |
184 |
|
|
"keysym_cmd : T_KEYSYM_CMD_VAR", |
185 |
|
|
"keysym_list : keysym_var", |
186 |
|
|
"keysym_list : keysym_var keysym_var", |
187 |
|
|
"keysym_list : keysym_var keysym_var keysym_var", |
188 |
|
|
"keysym_list : keysym_var keysym_var keysym_var keysym_var", |
189 |
|
|
"keysym_var : T_KEYSYM_VAR", |
190 |
|
|
"keysym_var : T_NUMBER", |
191 |
|
|
}; |
192 |
|
|
#endif |
193 |
|
|
#ifdef YYSTACKSIZE |
194 |
|
|
#undef YYMAXDEPTH |
195 |
|
|
#define YYMAXDEPTH YYSTACKSIZE |
196 |
|
|
#else |
197 |
|
|
#ifdef YYMAXDEPTH |
198 |
|
|
#define YYSTACKSIZE YYMAXDEPTH |
199 |
|
|
#else |
200 |
|
|
#define YYSTACKSIZE 10000 |
201 |
|
|
#define YYMAXDEPTH 10000 |
202 |
|
|
#endif |
203 |
|
|
#endif |
204 |
|
|
#define YYINITSTACKSIZE 200 |
205 |
|
|
/* LINTUSED */ |
206 |
|
|
int yydebug; |
207 |
|
|
int yynerrs; |
208 |
|
|
int yyerrflag; |
209 |
|
|
int yychar; |
210 |
|
|
short *yyssp; |
211 |
|
|
YYSTYPE *yyvsp; |
212 |
|
|
YYSTYPE yyval; |
213 |
|
|
YYSTYPE yylval; |
214 |
|
|
short *yyss; |
215 |
|
|
short *yysslim; |
216 |
|
|
YYSTYPE *yyvs; |
217 |
|
|
unsigned int yystacksize; |
218 |
|
|
int yyparse(void); |
219 |
|
|
#line 193 "map_parse.y" |
220 |
|
|
|
221 |
|
|
void |
222 |
|
|
yyerror(char *msg) |
223 |
|
|
{ |
224 |
|
|
errx(1, "parse: %s", msg); |
225 |
|
|
} |
226 |
|
|
#line 219 "map_parse.c" |
227 |
|
|
/* allocate initial stack or double stack size, up to YYMAXDEPTH */ |
228 |
|
|
static int yygrowstack(void) |
229 |
|
|
{ |
230 |
|
|
unsigned int newsize; |
231 |
|
|
long sslen; |
232 |
|
|
short *newss; |
233 |
|
|
YYSTYPE *newvs; |
234 |
|
|
|
235 |
|
|
if ((newsize = yystacksize) == 0) |
236 |
|
|
newsize = YYINITSTACKSIZE; |
237 |
|
|
else if (newsize >= YYMAXDEPTH) |
238 |
|
|
return -1; |
239 |
|
|
else if ((newsize *= 2) > YYMAXDEPTH) |
240 |
|
|
newsize = YYMAXDEPTH; |
241 |
|
|
sslen = yyssp - yyss; |
242 |
|
|
#ifdef SIZE_MAX |
243 |
|
|
#define YY_SIZE_MAX SIZE_MAX |
244 |
|
|
#else |
245 |
|
|
#define YY_SIZE_MAX 0xffffffffU |
246 |
|
|
#endif |
247 |
|
|
if (newsize && YY_SIZE_MAX / newsize < sizeof *newss) |
248 |
|
|
goto bail; |
249 |
|
|
newss = yyss ? (short *)realloc(yyss, newsize * sizeof *newss) : |
250 |
|
|
(short *)malloc(newsize * sizeof *newss); /* overflow check above */ |
251 |
|
|
if (newss == NULL) |
252 |
|
|
goto bail; |
253 |
|
|
yyss = newss; |
254 |
|
|
yyssp = newss + sslen; |
255 |
|
|
if (newsize && YY_SIZE_MAX / newsize < sizeof *newvs) |
256 |
|
|
goto bail; |
257 |
|
|
newvs = yyvs ? (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs) : |
258 |
|
|
(YYSTYPE *)malloc(newsize * sizeof *newvs); /* overflow check above */ |
259 |
|
|
if (newvs == NULL) |
260 |
|
|
goto bail; |
261 |
|
|
yyvs = newvs; |
262 |
|
|
yyvsp = newvs + sslen; |
263 |
|
|
yystacksize = newsize; |
264 |
|
|
yysslim = yyss + newsize - 1; |
265 |
|
|
return 0; |
266 |
|
|
bail: |
267 |
|
|
if (yyss) |
268 |
|
|
free(yyss); |
269 |
|
|
if (yyvs) |
270 |
|
|
free(yyvs); |
271 |
|
|
yyss = yyssp = NULL; |
272 |
|
|
yyvs = yyvsp = NULL; |
273 |
|
|
yystacksize = 0; |
274 |
|
|
return -1; |
275 |
|
|
} |
276 |
|
|
|
277 |
|
|
#define YYABORT goto yyabort |
278 |
|
|
#define YYREJECT goto yyabort |
279 |
|
|
#define YYACCEPT goto yyaccept |
280 |
|
|
#define YYERROR goto yyerrlab |
281 |
|
|
int |
282 |
|
|
yyparse(void) |
283 |
|
|
{ |
284 |
|
|
int yym, yyn, yystate; |
285 |
|
|
#if YYDEBUG |
286 |
|
|
const char *yys; |
287 |
|
|
|
288 |
|
|
if ((yys = getenv("YYDEBUG"))) |
289 |
|
|
{ |
290 |
|
|
yyn = *yys; |
291 |
|
|
if (yyn >= '0' && yyn <= '9') |
292 |
|
|
yydebug = yyn - '0'; |
293 |
|
|
} |
294 |
|
|
#endif /* YYDEBUG */ |
295 |
|
|
|
296 |
|
|
yynerrs = 0; |
297 |
|
|
yyerrflag = 0; |
298 |
|
|
yychar = (-1); |
299 |
|
|
|
300 |
|
|
if (yyss == NULL && yygrowstack()) goto yyoverflow; |
301 |
|
|
yyssp = yyss; |
302 |
|
|
yyvsp = yyvs; |
303 |
|
|
*yyssp = yystate = 0; |
304 |
|
|
|
305 |
|
|
yyloop: |
306 |
|
|
if ((yyn = yydefred[yystate]) != 0) goto yyreduce; |
307 |
|
|
if (yychar < 0) |
308 |
|
|
{ |
309 |
|
|
if ((yychar = yylex()) < 0) yychar = 0; |
310 |
|
|
#if YYDEBUG |
311 |
|
|
if (yydebug) |
312 |
|
|
{ |
313 |
|
|
yys = 0; |
314 |
|
|
if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; |
315 |
|
|
if (!yys) yys = "illegal-symbol"; |
316 |
|
|
printf("%sdebug: state %d, reading %d (%s)\n", |
317 |
|
|
YYPREFIX, yystate, yychar, yys); |
318 |
|
|
} |
319 |
|
|
#endif |
320 |
|
|
} |
321 |
|
|
if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && |
322 |
|
|
yyn <= YYTABLESIZE && yycheck[yyn] == yychar) |
323 |
|
|
{ |
324 |
|
|
#if YYDEBUG |
325 |
|
|
if (yydebug) |
326 |
|
|
printf("%sdebug: state %d, shifting to state %d\n", |
327 |
|
|
YYPREFIX, yystate, yytable[yyn]); |
328 |
|
|
#endif |
329 |
|
|
if (yyssp >= yysslim && yygrowstack()) |
330 |
|
|
{ |
331 |
|
|
goto yyoverflow; |
332 |
|
|
} |
333 |
|
|
*++yyssp = yystate = yytable[yyn]; |
334 |
|
|
*++yyvsp = yylval; |
335 |
|
|
yychar = (-1); |
336 |
|
|
if (yyerrflag > 0) --yyerrflag; |
337 |
|
|
goto yyloop; |
338 |
|
|
} |
339 |
|
|
if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && |
340 |
|
|
yyn <= YYTABLESIZE && yycheck[yyn] == yychar) |
341 |
|
|
{ |
342 |
|
|
yyn = yytable[yyn]; |
343 |
|
|
goto yyreduce; |
344 |
|
|
} |
345 |
|
|
if (yyerrflag) goto yyinrecovery; |
346 |
|
|
#if defined(__GNUC__) |
347 |
|
|
goto yynewerror; |
348 |
|
|
#endif |
349 |
|
|
yynewerror: |
350 |
|
|
yyerror("syntax error"); |
351 |
|
|
#if defined(__GNUC__) |
352 |
|
|
goto yyerrlab; |
353 |
|
|
#endif |
354 |
|
|
yyerrlab: |
355 |
|
|
++yynerrs; |
356 |
|
|
yyinrecovery: |
357 |
|
|
if (yyerrflag < 3) |
358 |
|
|
{ |
359 |
|
|
yyerrflag = 3; |
360 |
|
|
for (;;) |
361 |
|
|
{ |
362 |
|
|
if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 && |
363 |
|
|
yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) |
364 |
|
|
{ |
365 |
|
|
#if YYDEBUG |
366 |
|
|
if (yydebug) |
367 |
|
|
printf("%sdebug: state %d, error recovery shifting\ |
368 |
|
|
to state %d\n", YYPREFIX, *yyssp, yytable[yyn]); |
369 |
|
|
#endif |
370 |
|
|
if (yyssp >= yysslim && yygrowstack()) |
371 |
|
|
{ |
372 |
|
|
goto yyoverflow; |
373 |
|
|
} |
374 |
|
|
*++yyssp = yystate = yytable[yyn]; |
375 |
|
|
*++yyvsp = yylval; |
376 |
|
|
goto yyloop; |
377 |
|
|
} |
378 |
|
|
else |
379 |
|
|
{ |
380 |
|
|
#if YYDEBUG |
381 |
|
|
if (yydebug) |
382 |
|
|
printf("%sdebug: error recovery discarding state %d\n", |
383 |
|
|
YYPREFIX, *yyssp); |
384 |
|
|
#endif |
385 |
|
|
if (yyssp <= yyss) goto yyabort; |
386 |
|
|
--yyssp; |
387 |
|
|
--yyvsp; |
388 |
|
|
} |
389 |
|
|
} |
390 |
|
|
} |
391 |
|
|
else |
392 |
|
|
{ |
393 |
|
|
if (yychar == 0) goto yyabort; |
394 |
|
|
#if YYDEBUG |
395 |
|
|
if (yydebug) |
396 |
|
|
{ |
397 |
|
|
yys = 0; |
398 |
|
|
if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; |
399 |
|
|
if (!yys) yys = "illegal-symbol"; |
400 |
|
|
printf("%sdebug: state %d, error recovery discards token %d (%s)\n", |
401 |
|
|
YYPREFIX, yystate, yychar, yys); |
402 |
|
|
} |
403 |
|
|
#endif |
404 |
|
|
yychar = (-1); |
405 |
|
|
goto yyloop; |
406 |
|
|
} |
407 |
|
|
yyreduce: |
408 |
|
|
#if YYDEBUG |
409 |
|
|
if (yydebug) |
410 |
|
|
printf("%sdebug: state %d, reducing by rule %d (%s)\n", |
411 |
|
|
YYPREFIX, yystate, yyn, yyrule[yyn]); |
412 |
|
|
#endif |
413 |
|
|
yym = yylen[yyn]; |
414 |
|
|
if (yym) |
415 |
|
|
yyval = yyvsp[1-yym]; |
416 |
|
|
else |
417 |
|
|
memset(&yyval, 0, sizeof yyval); |
418 |
|
|
switch (yyn) |
419 |
|
|
{ |
420 |
|
|
case 1: |
421 |
|
|
#line 97 "map_parse.y" |
422 |
|
|
{ |
423 |
|
|
int i; |
424 |
|
|
struct wscons_keymap *mp; |
425 |
|
|
|
426 |
|
|
for (i = 0; i < KS_NUMKEYCODES; i++) { |
427 |
|
|
mp = mapdata + i; |
428 |
|
|
mp->command = KS_voidSymbol; |
429 |
|
|
mp->group1[0] = KS_voidSymbol; |
430 |
|
|
mp->group1[1] = KS_voidSymbol; |
431 |
|
|
mp->group2[0] = KS_voidSymbol; |
432 |
|
|
mp->group2[1] = KS_voidSymbol; |
433 |
|
|
} |
434 |
|
|
|
435 |
|
|
newkbmap.maplen = 0; |
436 |
|
|
newkbmap.map = mapdata; |
437 |
|
|
} |
438 |
|
|
break; |
439 |
|
|
case 7: |
440 |
|
|
#line 123 "map_parse.y" |
441 |
|
|
{ |
442 |
|
|
int src, dst; |
443 |
|
|
|
444 |
|
|
dst = ksym_lookup(yyvsp[-2].kval); |
445 |
|
|
src = ksym_lookup(yyvsp[0].kval); |
446 |
|
|
newkbmap.map[dst] = kbmap.map[src]; |
447 |
|
|
if (dst >= newkbmap.maplen) |
448 |
|
|
newkbmap.maplen = dst + 1; |
449 |
|
|
} |
450 |
|
|
break; |
451 |
|
|
case 8: |
452 |
|
|
#line 134 "map_parse.y" |
453 |
|
|
{ |
454 |
|
|
if (yyvsp[-1].ival >= KS_NUMKEYCODES) |
455 |
|
|
errx(1, "%d: keycode too large", yyvsp[-1].ival); |
456 |
|
|
if (yyvsp[-1].ival >= newkbmap.maplen) |
457 |
|
|
newkbmap.maplen = yyvsp[-1].ival + 1; |
458 |
|
|
cur_mp = mapdata + yyvsp[-1].ival; |
459 |
|
|
} |
460 |
|
|
break; |
461 |
|
|
case 11: |
462 |
|
|
#line 144 "map_parse.y" |
463 |
|
|
{ |
464 |
|
|
cur_mp->command = yyvsp[0].kval; |
465 |
|
|
} |
466 |
|
|
break; |
467 |
|
|
case 12: |
468 |
|
|
#line 149 "map_parse.y" |
469 |
|
|
{ |
470 |
|
|
cur_mp->group1[0] = yyvsp[0].kval; |
471 |
|
|
cur_mp->group1[1] = ksym_upcase(cur_mp->group1[0]); |
472 |
|
|
cur_mp->group2[0] = cur_mp->group1[0]; |
473 |
|
|
cur_mp->group2[1] = cur_mp->group1[1]; |
474 |
|
|
} |
475 |
|
|
break; |
476 |
|
|
case 13: |
477 |
|
|
#line 155 "map_parse.y" |
478 |
|
|
{ |
479 |
|
|
cur_mp->group1[0] = yyvsp[-1].kval; |
480 |
|
|
cur_mp->group1[1] = yyvsp[0].kval; |
481 |
|
|
cur_mp->group2[0] = cur_mp->group1[0]; |
482 |
|
|
cur_mp->group2[1] = cur_mp->group1[1]; |
483 |
|
|
} |
484 |
|
|
break; |
485 |
|
|
case 14: |
486 |
|
|
#line 161 "map_parse.y" |
487 |
|
|
{ |
488 |
|
|
cur_mp->group1[0] = yyvsp[-2].kval; |
489 |
|
|
cur_mp->group1[1] = yyvsp[-1].kval; |
490 |
|
|
cur_mp->group2[0] = yyvsp[0].kval; |
491 |
|
|
cur_mp->group2[1] = ksym_upcase(cur_mp->group2[0]); |
492 |
|
|
} |
493 |
|
|
break; |
494 |
|
|
case 15: |
495 |
|
|
#line 167 "map_parse.y" |
496 |
|
|
{ |
497 |
|
|
cur_mp->group1[0] = yyvsp[-3].kval; |
498 |
|
|
cur_mp->group1[1] = yyvsp[-2].kval; |
499 |
|
|
cur_mp->group2[0] = yyvsp[-1].kval; |
500 |
|
|
cur_mp->group2[1] = yyvsp[0].kval; |
501 |
|
|
} |
502 |
|
|
break; |
503 |
|
|
case 16: |
504 |
|
|
#line 175 "map_parse.y" |
505 |
|
|
{ |
506 |
|
|
yyval.kval = yyvsp[0].kval; |
507 |
|
|
} |
508 |
|
|
break; |
509 |
|
|
case 17: |
510 |
|
|
#line 178 "map_parse.y" |
511 |
|
|
{ |
512 |
|
|
char name[2]; |
513 |
|
|
int res; |
514 |
|
|
|
515 |
|
|
if (yyvsp[0].ival < 0 || yyvsp[0].ival > 9) |
516 |
|
|
yyerror("keysym expected"); |
517 |
|
|
name[0] = yyvsp[0].ival + '0'; |
518 |
|
|
name[1] = '\0'; |
519 |
|
|
res = name2ksym(name); |
520 |
|
|
if (res < 0) |
521 |
|
|
yyerror("keysym expected"); |
522 |
|
|
yyval.kval = res; |
523 |
|
|
} |
524 |
|
|
break; |
525 |
|
|
#line 518 "map_parse.c" |
526 |
|
|
} |
527 |
|
|
yyssp -= yym; |
528 |
|
|
yystate = *yyssp; |
529 |
|
|
yyvsp -= yym; |
530 |
|
|
yym = yylhs[yyn]; |
531 |
|
|
if (yystate == 0 && yym == 0) |
532 |
|
|
{ |
533 |
|
|
#if YYDEBUG |
534 |
|
|
if (yydebug) |
535 |
|
|
printf("%sdebug: after reduction, shifting from state 0 to\ |
536 |
|
|
state %d\n", YYPREFIX, YYFINAL); |
537 |
|
|
#endif |
538 |
|
|
yystate = YYFINAL; |
539 |
|
|
*++yyssp = YYFINAL; |
540 |
|
|
*++yyvsp = yyval; |
541 |
|
|
if (yychar < 0) |
542 |
|
|
{ |
543 |
|
|
if ((yychar = yylex()) < 0) yychar = 0; |
544 |
|
|
#if YYDEBUG |
545 |
|
|
if (yydebug) |
546 |
|
|
{ |
547 |
|
|
yys = 0; |
548 |
|
|
if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; |
549 |
|
|
if (!yys) yys = "illegal-symbol"; |
550 |
|
|
printf("%sdebug: state %d, reading %d (%s)\n", |
551 |
|
|
YYPREFIX, YYFINAL, yychar, yys); |
552 |
|
|
} |
553 |
|
|
#endif |
554 |
|
|
} |
555 |
|
|
if (yychar == 0) goto yyaccept; |
556 |
|
|
goto yyloop; |
557 |
|
|
} |
558 |
|
|
if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && |
559 |
|
|
yyn <= YYTABLESIZE && yycheck[yyn] == yystate) |
560 |
|
|
yystate = yytable[yyn]; |
561 |
|
|
else |
562 |
|
|
yystate = yydgoto[yym]; |
563 |
|
|
#if YYDEBUG |
564 |
|
|
if (yydebug) |
565 |
|
|
printf("%sdebug: after reduction, shifting from state %d \ |
566 |
|
|
to state %d\n", YYPREFIX, *yyssp, yystate); |
567 |
|
|
#endif |
568 |
|
|
if (yyssp >= yysslim && yygrowstack()) |
569 |
|
|
{ |
570 |
|
|
goto yyoverflow; |
571 |
|
|
} |
572 |
|
|
*++yyssp = yystate; |
573 |
|
|
*++yyvsp = yyval; |
574 |
|
|
goto yyloop; |
575 |
|
|
yyoverflow: |
576 |
|
|
yyerror("yacc stack overflow"); |
577 |
|
|
yyabort: |
578 |
|
|
if (yyss) |
579 |
|
|
free(yyss); |
580 |
|
|
if (yyvs) |
581 |
|
|
free(yyvs); |
582 |
|
|
yyss = yyssp = NULL; |
583 |
|
|
yyvs = yyvsp = NULL; |
584 |
|
|
yystacksize = 0; |
585 |
|
|
return (1); |
586 |
|
|
yyaccept: |
587 |
|
|
if (yyss) |
588 |
|
|
free(yyss); |
589 |
|
|
if (yyvs) |
590 |
|
|
free(yyvs); |
591 |
|
|
yyss = yyssp = NULL; |
592 |
|
|
yyvs = yyvsp = NULL; |
593 |
|
|
yystacksize = 0; |
594 |
|
|
return (0); |
595 |
|
|
} |