xref: /illumos-gate/usr/src/cmd/geniconvtbl/itm_comp.y (revision 2a8bcb4efb45d99ac41c94a75c396b362c414f7f)
1 %{
2 /*
3  * CDDL HEADER START
4  *
5  * The contents of this file are subject to the terms of the
6  * Common Development and Distribution License, Version 1.0 only
7  * (the "License").  You may not use this file except in compliance
8  * with the License.
9  *
10  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11  * or http://www.opensolaris.org/os/licensing.
12  * See the License for the specific language governing permissions
13  * and limitations under the License.
14  *
15  * When distributing Covered Code, include this CDDL HEADER in each
16  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17  * If applicable, add the following below this CDDL HEADER, with the
18  * fields enclosed by brackets "[]" replaced with your own identifying
19  * information: Portions Copyright [yyyy] [name of copyright owner]
20  *
21  * CDDL HEADER END
22  *
23  * Copyright (c) 1999 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <ctype.h>
30 #include <libintl.h>
31 #include <errno.h>
32 
33 #include "iconv_tm.h"
34 #include "itmcomp.h"
35 #include "itm_util.h"
36 
37 %}
38 
39 %start itm_def
40 
41 %union		yystacktype
42 {
43 	int		intval;
44 
45 	itm_num_t	num;
46 	itm_data_t	*name;
47 	itm_data_t	*data;
48 
49 	itm_tbl_hdr_t	*tbl_hdr;
50 	itm_direc_t	*direc_unit;
51 	itm_expr_t	*expr;
52 
53 	itmc_action_t	action;
54 	itmc_obj_t	*obj;
55 	itmc_map_t	*map_list;
56 	itmc_ref_t	*itmc_ref;
57 	itmc_map_attr_t	*map_attr;
58 }
59 
60 %type <intval>		itm_def
61 %type <obj>		def_element_list
62 %type <tbl_hdr>		def_element
63 
64 %type <tbl_hdr>		direction
65 %type <obj>		direction_unit_list
66 %type <obj>		direction_unit
67 
68 %type <action>		action
69 
70 %type <itmc_ref>	condition
71 %type <obj>		condition_list
72 %type <obj>		condition_expr
73 
74 %type <obj>		range_list
75 %type <obj>		range_pair
76 
77 %type <obj>		escseq_list
78 %type <obj>		escseq
79 
80 %type <tbl_hdr>		map
81 %type <map_list>	map_list
82 %type <map_list>	map_pair
83 %type <map_attr>	map_attribute
84 %type <intval>		map_resultlen
85 %type <map_attr>	map_type
86 %type <name>		map_type_names
87 
88 %type <tbl_hdr>		operation
89 %type <obj>		op_list
90 %type <obj>		op_unit
91 %type <obj>		op_if_else
92 
93 %type <data>		name
94 
95 %type <expr>		expr
96 %type <expr>		itm_in
97 
98 %token	<name> ITMNAME
99 %token	<name> NAME
100 %token	<name> MAPTYPE_NAME
101 %token	<data> HEXADECIMAL
102 %token	<num>  DECIMAL
103 
104 %token ITM_DEFAULT
105 %token ITM_IDENTICAL
106 
107 %token BETWEEN
108 %token BREAK
109 %token CONDITION
110 %token DIRECTION
111 %token DISCARD
112 %token ERROR
113 %token ITM_ELSE
114 %token ITM_INIT
115 %token ITM_FALSE
116 %token ITM_IF
117 %token ITM_IN
118 %token ITM_INSIZE
119 %token NOP
120 %token OPERATION
121 %token ITM_OUT
122 %token ITM_OUTSIZE
123 %token PRINTCHR
124 %token PRINTHD
125 %token PRINTINT
126 %token MAP
127 %token RESET
128 %token RETURN
129 %token ITM_TRUE
130 %token ESCAPESEQ
131 %token MAPTYPE
132 %token RESULTLEN
133 
134 
135 %token MAPTYPE_AUTO
136 %token MAPTYPE_INDEX
137 %token MAPTYPE_DENSE
138 %token MAPTYPE_HASH
139 %token MAPTYPE_BINARY
140 
141 %token ELLIPSES
142 %token CBO CBC
143 %token SBO SBC
144 %token PO PC
145 %token SC
146 %token COMMA
147 %token COLON
148 
149 %right ASSIGN
150 %left LOR
151 %left LAND
152 %left OR
153 %left XOR
154 %left AND
155 %left EQ NE
156 %left LT LE GT GE
157 %left SHL SHR
158 %left PLUS MINUS
159 %left MUL DIV MOD
160 %right NOT NEG UMINUS
161 
162 %%
163 
164 itm_def
165 	: ITMNAME CBO def_element_list CBC
166 	{
167 		itm_def_process($1);
168 	}
169 	;
170 
171 def_element_list
172 	: def_element SC
173 	{
174 		TRACE_MESSAGE('y', ("def_element_list: def_element ;\n"));
175 		$$ = NULL;
176 	}
177 	| def_element_list def_element SC
178 	{
179 		TRACE_MESSAGE('y',
180 			("def_element_list: def_element_list def_element ;\n"));
181 		$$ = NULL;
182 	}
183 	;
184 
185 def_element
186 	: direction
187 	{
188 		TRACE_MESSAGE('y', ("def_element: direction\n"));
189 		(void) obj_register(ITMC_OBJ_DIREC, (itm_data_t *)($1->name.itm_ptr),
190 			$1, $1->size,
191 			NULL, OBJ_REG_TAIL);
192 		$$ = $1;
193 	}
194 	| condition
195 	{
196 		TRACE_MESSAGE('y', ("def_element: condition\n"));
197 		$$ = (itm_tbl_hdr_t *)($1->referencee);
198 	}
199 	| map
200 	{
201 		TRACE_MESSAGE('y', ("def_element: map\n"));
202 		if (NULL != $1) {
203 			(void) obj_register(ITMC_OBJ_MAP,
204 				(itm_data_t *)($1->name.itm_ptr),
205 				$1, $1->size,
206 				NULL, OBJ_REG_TAIL);
207 	}
208 		$$ = $1;
209 	}
210 	| operation
211 	{
212 		TRACE_MESSAGE('y', ("def_element: operation\n"));
213 		(void) obj_register(ITMC_OBJ_OP, (itm_data_t *)($1->name.itm_ptr),
214 			$1, $1->size,
215 			NULL, OBJ_REG_TAIL);
216 		$$ = $1;
217 	}
218 	;
219 
220 direction
221 	: DIRECTION name CBO direction_unit_list CBC
222 	{
223 		TRACE_MESSAGE('y', ("direction name (direction_unit_list)\n"));
224 		$$ = obj_table(ITM_TBL_DIREC, $2,
225 			$4, sizeof (itm_direc_t));
226 	}
227 	| DIRECTION CBO direction_unit_list CBC
228 	{
229 		TRACE_MESSAGE('y', ("direction name (direction_unit_list)\n"));
230 		$$ = obj_table(ITM_TBL_DIREC, NULL,
231 			$3, sizeof (itm_direc_t));
232 	}
233 	;
234 
235 direction_unit_list
236 	: direction_unit
237 	{
238 		TRACE_MESSAGE('y', ("direction_unit_list: direction_unit\n"));
239 		$$ = obj_list_append(NULL, $1);
240 	}
241 	| direction_unit_list direction_unit
242 	{
243 		TRACE_MESSAGE('y', ("direction_unit_list: "
244 			"direction_unit_list direction_unit\n"));
245 		$$ = obj_list_append($1, $2);
246 	}
247 	;
248 
249 direction_unit
250 	: condition action SC
251 	{
252 		TRACE_MESSAGE('y', ("direction_unit: condition action ;\n"));
253 		$$ = direction_unit($1, NULL, &($2), NULL);
254 	}
255 	| condition name SC
256 	{
257 		itm_direc_t	*direc;
258 		TRACE_MESSAGE('y', ("direction_unit: condition NAME ;\n"));
259 		$$ = direction_unit($1, NULL, NULL, $2);
260 	}
261 	| name action SC
262 	{
263 		itm_direc_t	*direc;
264 		TRACE_MESSAGE('y', ("direction_unit: NAME action ;\n"));
265 		$$ = direction_unit(NULL, $1, &($2), NULL);
266 	}
267 	| name name SC
268 	{
269 		itm_direc_t	*direc;
270 		TRACE_MESSAGE('y', ("direction_unit: NAME NAME ;\n"));
271 		$$ = direction_unit(NULL, $1, NULL, $2);
272 	}
273 	| ITM_TRUE action SC
274 	{
275 		itm_direc_t	*direc;
276 		$$ = direction_unit(NULL, NULL, &($2), NULL);
277 	}
278 	| ITM_TRUE name SC
279 	{
280 		itm_direc_t	*direc;
281 		TRACE_MESSAGE('y', ("direction_unit: TRUE NAME ;\n"));
282 		$$ = direction_unit(NULL, NULL, NULL, $2);
283 	}
284 	;
285 
286 action
287 	: direction
288 	{
289 		TRACE_MESSAGE('y', ("action: direction\n"));
290 		$$.type = ITMC_OBJ_DIREC;
291 		$$.tbl_hdr = $1;
292 	}
293 	| map
294 	{
295 		TRACE_MESSAGE('y', ("action: map\n"));
296 		$$.type = ITMC_OBJ_MAP;
297 		$$.tbl_hdr = $1;
298 	}
299 	| operation
300 	{
301 		TRACE_MESSAGE('y', ("action: operation\n"));
302 		$$.type = ITMC_OBJ_OP;
303 		$$.tbl_hdr = $1;
304 	}
305 	;
306 
307 condition
308 	: CONDITION name CBO condition_list CBC
309 	{
310 		itm_tbl_hdr_t	*tbl_hdr;
311 		TRACE_MESSAGE('y', ("condition\n"));
312 		tbl_hdr = obj_table(ITM_TBL_COND, $2,
313 				    $4, sizeof (itm_cond_t));
314 		$$ = obj_register(ITMC_OBJ_COND, $2,
315 				tbl_hdr, tbl_hdr->size,
316 				NULL, OBJ_REG_TAIL);
317 	}
318 	| CONDITION CBO condition_list CBC
319 	{
320 		itm_tbl_hdr_t	*tbl_hdr;
321 		TRACE_MESSAGE('y', ("condition\n"));
322 		tbl_hdr = obj_table(ITM_TBL_COND, NULL,
323 				    $3, sizeof (itm_cond_t));
324 		$$ = obj_register(ITMC_OBJ_COND, NULL,
325 				tbl_hdr, tbl_hdr->size,
326 				NULL, OBJ_REG_TAIL);
327 	}
328 	;
329 
330 condition_list
331 	: condition_expr SC
332 	{
333 		TRACE_MESSAGE('y', ("condition_list: condition_expr;\n"));
334 		$$ = obj_list_append(NULL, $1);
335 	}
336 	| condition_list condition_expr SC
337 	{
338 		TRACE_MESSAGE('y', ("condition_list: "
339 			"condition_list condition_expr;\n"));
340 		$$ = obj_list_append($1, $2);
341 	}
342 	;
343 
344 condition_expr
345 	: BETWEEN range_list
346 	{
347 		itm_tbl_hdr_t	*range;
348 		itm_cond_t	*cond;
349 		TRACE_MESSAGE('y', ("condition_expr: between\n"));
350 		range = range_table(NULL, $2);
351 		if (range == NULL) {
352 			$$ = NULL;
353 		} else {
354 			$$ = malloc_vital(sizeof (itmc_obj_t));
355 			$$->type = ITMC_OBJ_RANGE;
356 			$$->name = NULL;
357 			cond = malloc_vital(sizeof (itm_cond_t));
358 			$$->obj = cond;
359 			cond->type = ITM_COND_BETWEEN;
360 			cond->operand.place.itm_ptr = (itm_place2_t)range;
361 			$$->ref[0] = obj_register(ITMC_OBJ_RANGE, NULL,
362 					range, range->size,
363 					&(cond->operand.place),
364 					OBJ_REG_TAIL);
365 			$$->ref[1] = NULL;
366 			$$->ref[2] = NULL;
367 			$$->next = $$->last = NULL;
368 		}
369 	}
370 	| expr
371 	{
372 		itm_cond_t	*cond;
373 		TRACE_MESSAGE('y', ("condition_expr: expr\n"));
374 		$$ = malloc_vital(sizeof (itmc_obj_t));
375 		$$->type = ITMC_OBJ_EXPR;
376 		$$->name = NULL;
377 		cond = malloc_vital(sizeof (itm_cond_t));
378 		$$->obj = cond;
379 		cond->type = ITM_COND_EXPR;
380 		cond->operand.place.itm_ptr = (itm_place2_t)($1);
381 		$$->ref[0] = obj_register(ITMC_OBJ_EXPR, NULL,
382 					$1, sizeof (itm_expr_t),
383 					&(cond->operand.place),
384 					OBJ_REG_TAIL);
385 		$$->ref[1] = NULL;
386 		$$->ref[2] = NULL;
387 		$$->next = $$->last = NULL;
388 	}
389 	| ESCAPESEQ escseq_list
390 	{
391 		itm_tbl_hdr_t	*escseq;
392 		itm_cond_t	*cond;
393 		TRACE_MESSAGE('y', ("condition_expr:  escseq {escseq_list;}\n"));
394 		escseq = escseq_table(NULL, $2);
395 		if (escseq == NULL) {
396 			$$ = NULL;
397 		} else {
398 			$$ = malloc_vital(sizeof (itmc_obj_t));
399 			$$->type = ITMC_OBJ_ESCAPESEQ;
400 			$$->name = NULL;
401 			cond = malloc_vital(sizeof (itm_cond_t));
402 			$$->obj = cond;
403 			cond->type = ITM_COND_ESCAPESEQ;
404 			cond->operand.place.itm_ptr = (itm_place2_t)escseq;
405 			$$->ref[0] = obj_register(ITMC_OBJ_ESCAPESEQ, NULL,
406 					escseq, escseq->size,
407 					&(cond->operand.place),
408 					OBJ_REG_TAIL);
409 			$$->ref[1] = NULL;
410 			$$->ref[2] = NULL;
411 			$$->next = $$->last = NULL;
412 		}
413 	}
414 	;
415 
416 range_list
417 	: range_pair
418 	{
419 		TRACE_MESSAGE('y', ("range_list: range_pair\n"));
420 		$$ = obj_list_append(NULL, $1);
421 	}
422 	| range_list COMMA range_pair
423 	{
424 		TRACE_MESSAGE('y', ("range_list: range_list, range_pair\n"));
425 		$$ = obj_list_append($1, $3);
426 	}
427 	;
428 
429 range_pair
430 	: HEXADECIMAL ELLIPSES HEXADECIMAL
431 	{
432 		itmc_data_pair_t	*range;
433 		TRACE_MESSAGE('y', ("range_pair: HEXADECIMAL...HEXADECIMAL\n"));
434 		$$ = malloc_vital(sizeof (itmc_obj_t));
435 		$$->type = ITMC_OBJ_RANGE;
436 		$$->name = NULL;
437 		range = malloc_vital(sizeof (itmc_data_pair_t));
438 		$$->obj = range;
439 		if (data_compare($1, $3) < 0) {
440 			range->data0 = *($1);
441 			range->data1 = *($3);
442 		} else {
443 			range->data0 = *($3);
444 			range->data1 = *($1);
445 		}
446 	}
447 	;
448 escseq_list
449 	: escseq
450 	{
451 		TRACE_MESSAGE('y', ("escseq_list: escseq\n"));
452 		$$ = obj_list_append(NULL, $1);
453 	}
454 	| escseq_list COMMA escseq
455 	{
456 		TRACE_MESSAGE('y', ("escseq_list: escseq_list; escseq\n"));
457 		$$ = obj_list_append($1, $3);
458 	}
459 	;
460 
461 escseq
462 	: HEXADECIMAL
463 	{
464 		itm_data_t	*escseq;
465 		TRACE_MESSAGE('y', ("escseq: HEXADECIMAL\n"));
466 		$$ = malloc_vital(sizeof (itmc_obj_t));
467 		$$->type = ITMC_OBJ_ESCAPESEQ;
468 		$$->name = NULL;
469 		escseq = malloc_vital(sizeof (itm_data_t));
470 		$$->obj = escseq;
471 		*escseq = *($1);
472 	}
473 	;
474 
475 map	: MAP name CBO map_list CBC
476 	{
477 		TRACE_MESSAGE('y', ("map: map name {map_list}\n"));
478 		$$ = map_table($2, $4, NULL);
479 	}
480 	| MAP CBO map_list CBC
481 	{
482 		TRACE_MESSAGE('y', ("map: map {map_list}\n"));
483 		$$ = map_table(NULL, $3, NULL);
484 	}
485 	| MAP name map_attribute CBO map_list CBC
486 	{
487 		TRACE_MESSAGE('y', ("map: map name attribute {map_list}\n"));
488 		$$ = map_table($2, $5, $3);
489 	}
490 	| MAP map_attribute CBO map_list CBC
491 	{
492 		TRACE_MESSAGE('y', ("map: map attribute {map_list}\n"));
493 		$$ = map_table(NULL, $4, $2);
494 	}
495 	;
496 
497 map_attribute
498 	:map_type COMMA map_resultlen
499 	{
500 		TRACE_MESSAGE('y', ("map_attribute: map_type map_resultlen\n"));
501 		$$ = $1;
502 		$$->resultlen = $3;
503 	}
504 	|map_type
505 	{
506 		TRACE_MESSAGE('y', ("map_attribute: map_type\n"));
507 		$$ = $1;
508 		$$->resultlen = 0;
509 	}
510 	|map_resultlen COMMA map_type
511 	{
512 		TRACE_MESSAGE('y', ("map_attribute: map_resultlen map_type\n"));
513 		$$ = $3;
514 		$$->resultlen = $1;
515 	}
516 	|map_resultlen
517 	{
518 		TRACE_MESSAGE('y', ("map_attribute: map_resultlen\n"));
519 		$$ = malloc_vital(sizeof (itmc_map_attr_t));
520 		$$->resultlen = $1;
521 		$$->type = NULL;
522 		$$->hash_factor = 0;
523 	}
524 	;
525 
526 map_type
527 	: MAPTYPE ASSIGN map_type_names COLON DECIMAL
528 	{
529 		TRACE_MESSAGE('y', ("map_type: maptype=type:factor(%d)\n",
530 			$5));
531 		$$ = malloc_vital(sizeof (itmc_map_attr_t));
532 		$$->type = $3;
533 		$$->hash_factor = $5;
534 	}
535 	| MAPTYPE ASSIGN map_type_names
536 	{
537 		TRACE_MESSAGE('y', ("map_type: maptype=type\n"));
538 		$$ = malloc_vital(sizeof (itmc_map_attr_t));
539 		$$->type  = $3;
540 		$$->hash_factor = 0;
541 	}
542 	;
543 
544 map_type_names
545 	: MAPTYPE_NAME
546 	{
547 		TRACE_MESSAGE('y', ("map_type_names: size=%*s\n",
548 				yylval.data->size, NSPTR(yylval.data)));
549 		$$ = yylval.data;
550 	}
551 	;
552 
553 
554 map_resultlen
555 	: RESULTLEN ASSIGN DECIMAL
556 	{
557 		TRACE_MESSAGE('y', ("map_resultlen(%d)\n", $3));
558 		$$ = $3;
559 	}
560 	;
561 
562 map_list
563 	: map_pair
564 	{
565 		TRACE_MESSAGE('y', ("map_list: map_pair\n"));
566 		$$ = map_list_append(NULL, $1);
567 	}
568 	| map_list map_pair
569 	{
570 		TRACE_MESSAGE('y', ("map_list: map_list map_pair\n"));
571 		$$ = map_list_append($1, $2);
572 	}
573 	;
574 
575 map_pair
576 	: HEXADECIMAL HEXADECIMAL
577 	{
578 		TRACE_MESSAGE('y', ("map_pair: HEXADECIMAL HEXADECIMAL\n"));
579 		$$ = malloc_vital(sizeof (itmc_map_t));
580 		$$->data_pair.data0 = *($1);
581 		free($1);
582 		$$->data_pair.data1 = *($2);
583 		free($2);
584 	}
585 	| HEXADECIMAL ELLIPSES HEXADECIMAL HEXADECIMAL
586 	{
587 		TRACE_MESSAGE('y', ("map_pair: "
588 			"HEXADECIMAL ELLIPSES HEXADECIMAL\n"));
589 		$$ = malloc_vital(sizeof (itmc_map_t));
590 		$$->data_pair.data0 = *($1);
591 		$$->data_pair.range = *($3);
592 		free($1);
593 		free($3);
594 		$$->data_pair.data1 = *($4);
595 		free($4);
596 	}
597 	| ITM_DEFAULT  HEXADECIMAL
598 	{
599 		TRACE_MESSAGE('y', ("map_pair: default HEXADECIMAL\n"));
600 		$$ = malloc_vital(sizeof (itmc_map_t));
601 		$$->data_pair.data0.size = 0;
602 		$$->data_pair.data1 = *($2);
603 		free($2);
604 	}
605 	| ITM_DEFAULT  ITM_IDENTICAL
606 	{
607 		TRACE_MESSAGE('y', ("map_pair: default default\n"));
608 		$$ = malloc_vital(sizeof (itmc_map_t));
609 		$$->data_pair.data0.size = 0;
610 		$$->data_pair.data1.size = 0;
611 	}
612 	| HEXADECIMAL ERROR /* NO RANGE */
613 	{
614 		TRACE_MESSAGE('y', ("map_pair: hexadecimal error\n"));
615 		$$ = malloc_vital(sizeof (itmc_map_t));
616 		$$->data_pair.data0 = *($1);
617 		free($1);
618 		$$->data_pair.data1.size = 0;
619 	}
620 	;
621 
622 operation
623 	: OPERATION name CBO op_list CBC
624 	{
625 		TRACE_MESSAGE('y', ("operation: operation name {op_list}\n"));
626 		$$ = obj_table(ITM_TBL_OP, $2,
627 			$4, sizeof (itm_op_t));
628 	}
629 	| OPERATION CBO op_list CBC
630 	{
631 		TRACE_MESSAGE('y', ("operation: operation {op_list}\n"));
632 		$$ = obj_table(ITM_TBL_OP, NULL,
633 				$3, sizeof (itm_op_t));
634 	}
635 	| OPERATION ITM_INIT CBO op_list CBC
636 	{
637 		TRACE_MESSAGE('y', ("operation: operation init {op_list}\n"));
638 		$$ = obj_table(ITM_TBL_OP_INIT, NULL,
639 			$4, sizeof (itm_op_t));
640 	}
641 	| OPERATION RESET CBO op_list CBC
642 	{
643 		TRACE_MESSAGE('y', ("operation: operation reset {op_list}\n"));
644 		$$ = obj_table(ITM_TBL_OP_RESET, NULL,
645 			$4, sizeof (itm_op_t));
646 	}
647 	;
648 
649 op_list	: op_unit
650 	{
651 		TRACE_MESSAGE('y', ("op_list: op_unit\n"));
652 		$$ = obj_list_append(NULL, $1);
653 	}
654 	| op_list op_unit
655 	{
656 		TRACE_MESSAGE('y', ("op_list: op_list op_unit\n"));
657 		$$ = obj_list_append($1, $2);
658 	}
659 	;
660 
661 op_unit	: /* */ SC
662 	{
663 		TRACE_MESSAGE('y', ("op_unit: /	*null */;\n"));
664 		$$ = NULL;
665 	}
666 	| expr SC
667 	{
668 		TRACE_MESSAGE('y', ("op_unit: expr;\n"));
669 		$$ = op_unary(ITM_OP_EXPR, $1, sizeof (itm_expr_t));
670 	}
671 	| ERROR SC
672 	{
673 		TRACE_MESSAGE('y', ("expr: error;\n"));
674 		$$ = op_self_num(ITM_OP_ERROR_D, EINVAL);
675 	}
676 	| ERROR expr SC
677 	{
678 		TRACE_MESSAGE('y', ("expr: error;\n"));
679 		if (ITM_EXPR_INT == $2->type) {
680 			$$ = op_self_num(ITM_OP_ERROR_D, $2->data.itm_exnum);
681 		} else {
682 			$$ = op_unary(ITM_OP_ERROR, $2, sizeof (itm_expr_t));
683 		}
684 	}
685 	| DISCARD SC
686 	{
687 		TRACE_MESSAGE('y', ("discard expr;\n"));
688 		$$ = op_self_num(ITM_OP_DISCARD_D, 1);
689 	}
690 	| DISCARD expr SC
691 	{
692 		TRACE_MESSAGE('y', ("discard expr;\n"));
693 		if (ITM_EXPR_INT == $2->type) {
694 			$$ = op_self_num(ITM_OP_DISCARD_D, $2->data.itm_exnum);
695 		} else {
696 			$$ = op_unary(ITM_OP_DISCARD, $2, sizeof (itm_expr_t));
697 		}
698 	}
699 	| ITM_OUT ASSIGN expr SC
700 	{
701 		TRACE_MESSAGE('y', ("out = expr;\n"));
702 		switch ($3->type) {
703 		case ITM_EXPR_INT:
704 			$$ = op_unary(ITM_OP_OUT_D, $3, sizeof (itm_expr_t));
705 			break;
706 		case ITM_EXPR_SEQ:
707 			$$ = op_unary(ITM_OP_OUT_S, $3, sizeof (itm_expr_t));
708 			break;
709 		case ITM_EXPR_REG:
710 			$$ = op_unary(ITM_OP_OUT_R, $3, sizeof (itm_expr_t));
711 			break;
712 		case ITM_EXPR_IN_VECTOR_D:
713 			$$ = op_unary(ITM_OP_OUT_INVD, $3, sizeof (itm_expr_t));
714 			break;
715 		default:
716 			$$ = op_unary(ITM_OP_OUT, $3, sizeof (itm_expr_t));
717 			break;
718 		}
719 	}
720 	| DIRECTION name SC
721 	{
722 		itm_op_t	*op;
723 		TRACE_MESSAGE('y', ("direction NAME;\n"));
724 		$$ = op_unit(ITM_OP_DIRECTION, NULL, 0, NULL, 0, NULL, 0);
725 		op = (itm_op_t *)($$->obj);
726 		op->data.operand[0].itm_ptr = (itm_place2_t)($2);
727 		$$->ref[0] = obj_register(ITMC_OBJ_DIREC, $2,
728 					NULL, 0,
729 					&(op->data.operand[0]), OBJ_REG_TAIL);
730 	}
731 	| OPERATION name SC
732 	{
733 		itm_op_t	*op;
734 		TRACE_MESSAGE('y', ("operation NAME;\n"));
735 		$$ = op_unit(ITM_OP_OPERATION, NULL, 0, NULL, 0, NULL, 0);
736 		op = (itm_op_t *)($$->obj);
737 		op->data.operand[0].itm_ptr = (itm_place2_t)($2);
738 		$$->ref[0] = obj_register(ITMC_OBJ_OP, $2,
739 					NULL, 0,
740 					&(op->data.operand[0]), OBJ_REG_TAIL);
741 	}
742 	| OPERATION ITM_INIT SC
743 	{
744 		itm_op_t	*op;
745 		TRACE_MESSAGE('y', ("operation init;\n"));
746 		$$ = op_self(ITM_OP_INIT);
747 	}
748 	| OPERATION RESET SC
749 	{
750 		itm_op_t	*op;
751 		TRACE_MESSAGE('y', ("operation reset;\n"));
752 		$$ = op_self(ITM_OP_RESET);
753 	}
754 	| MAP name SC
755 	{
756 		itm_op_t	*op;
757 		TRACE_MESSAGE('y', ("map NAME;\n"));
758 		$$ = op_unit(ITM_OP_MAP, NULL, 0, NULL, 0, NULL, 0);
759 		op = (itm_op_t *)($$->obj);
760 		op->data.operand[0].itm_ptr = (itm_place2_t)($2);
761 		$$->ref[0] = obj_register(ITMC_OBJ_MAP, $2,
762 					NULL, 0,
763 					&(op->data.operand[0]), OBJ_REG_TAIL);
764 	}
765 	| MAP name expr SC
766 	{
767 		itm_op_t	*op;
768 		TRACE_MESSAGE('y', ("map NAME expr;\n"));
769 		$$ = op_unit(ITM_OP_MAP, NULL, 0, $3,
770 			sizeof (itm_expr_t), NULL, 0);
771 		op = (itm_op_t *)($$->obj);
772 		op->data.operand[0].itm_ptr = (itm_place2_t)($2);
773 		$$->ref[0] = obj_register(ITMC_OBJ_MAP, $2,
774 					NULL, 0,
775 					&(op->data.operand[0]), OBJ_REG_TAIL);
776 	}
777 	| op_if_else
778 	{
779 		TRACE_MESSAGE('y', ("op_unit: op_if_else\n"));
780 		$$ = $1;
781 	}
782 	| BREAK SC
783 	{
784 		TRACE_MESSAGE('y', ("break;\n"));
785 		$$ = op_self(ITM_OP_BREAK);
786 	}
787 	| RETURN SC
788 	{
789 		TRACE_MESSAGE('y', ("return;\n"));
790 		$$ = op_self(ITM_OP_RETURN);
791 	}
792 	| PRINTCHR expr SC
793 	{
794 		TRACE_MESSAGE('y', ("printchr expr;\n"));
795 		$$ = op_unary(ITM_OP_PRINTCHR, $2, sizeof (itm_expr_t));
796 	}
797 	| PRINTHD expr SC
798 	{
799 		TRACE_MESSAGE('y', ("printchr expr;\n"));
800 		$$ = op_unary(ITM_OP_PRINTHD, $2, sizeof (itm_expr_t));
801 	}
802 	| PRINTINT expr SC
803 	{
804 		TRACE_MESSAGE('y', ("printint expr;\n"));
805 		$$ = op_unary(ITM_OP_PRINTINT, $2, sizeof (itm_expr_t));
806 	}
807 	;
808 
809 op_if_else
810 	: ITM_IF PO expr PC CBO op_list CBC
811 	{
812 		itm_tbl_hdr_t	*tbl_hdr;
813 		TRACE_MESSAGE('y', ("op_if_else: if (expr) {op_list}\n"));
814 		tbl_hdr = obj_table(ITM_TBL_OP, NULL,
815 				    $6, sizeof (itm_op_t));
816 		$$ = op_unit(ITM_OP_IF,
817 				$3, sizeof (itm_expr_t),
818 				tbl_hdr, tbl_hdr->size,
819 				NULL, 0);
820 	}
821 	| ITM_IF PO expr PC CBO op_list CBC ITM_ELSE op_if_else
822 	{
823 		itm_tbl_hdr_t	*tbl_hdr1;
824 		itm_tbl_hdr_t	*tbl_hdr2;
825 		TRACE_MESSAGE('y', ("op_if_else: "
826 			"if (expr) {op_list} else op_if_else\n"));
827 		tbl_hdr1 = obj_table(ITM_TBL_OP, NULL,
828 				    $6, sizeof (itm_op_t));
829 		tbl_hdr2 = obj_table(ITM_TBL_OP, NULL,
830 				    $9, sizeof (itm_op_t));
831 		$$ = op_unit(ITM_OP_IF_ELSE,
832 				$3, sizeof (itm_expr_t),
833 				tbl_hdr1, tbl_hdr1->size,
834 				tbl_hdr2, tbl_hdr2->size);
835 	}
836 	| ITM_IF PO expr PC CBO op_list CBC ITM_ELSE CBO op_list CBC
837 	{
838 		itm_tbl_hdr_t	*tbl_hdr1;
839 		itm_tbl_hdr_t	*tbl_hdr2;
840 		TRACE_MESSAGE('y', ("op_if_else: "
841 			"if (expr) {op_list} else {op_list}\n"));
842 		tbl_hdr1 = obj_table(ITM_TBL_OP, NULL,
843 				    $6, sizeof (itm_op_t));
844 		tbl_hdr2 = obj_table(ITM_TBL_OP, NULL,
845 				    $10, sizeof (itm_op_t));
846 		$$ = op_unit(ITM_OP_IF_ELSE,
847 				$3, sizeof (itm_expr_t),
848 				tbl_hdr1, tbl_hdr1->size,
849 				tbl_hdr2, tbl_hdr2->size);
850 	}
851 	;
852 
853 name	: NAME
854 	{
855 		TRACE_MESSAGE('y', ("name: size=%*s\n",
856 				yylval.data->size, NSPTR(yylval.data)));
857 		$$ = yylval.data;
858 	}
859 	;
860 
861 itm_in	: ITM_IN
862 	{
863 		TRACE_MESSAGE('y', ("in\n"));
864 		$$ = expr_self(ITM_EXPR_IN, NULL);
865 	}
866 	;
867 
868 expr	: PO expr PC
869 	{
870 		TRACE_MESSAGE('y', ("expr: (expr)\n"));
871 		$$ = $2;
872 	}
873 	| name
874 	{
875 		TRACE_MESSAGE('y', ("expr: NAME\n"));
876 		$$ = expr_self(ITM_EXPR_NAME, $1);
877 	}
878 	| HEXADECIMAL
879 	{
880 		TRACE_MESSAGE('y', ("expr: HEXADECIMAL\n"));
881 		$$ = expr_self(ITM_EXPR_SEQ, yylval.data);
882 	}
883 	| DECIMAL
884 	{
885 		TRACE_MESSAGE('y', ("expr: DECIMAL\n"));
886 		$$ = expr_self_num(ITM_EXPR_INT, yylval.num);
887 	}
888 	| itm_in SBO expr SBC
889 	{
890 		if (ITM_EXPR_INT == $3->type) {
891 			TRACE_MESSAGE('y', ("expr: in[%ld]\n",
892 				$3->data.itm_exnum));
893 			$$ = expr_self_num(ITM_EXPR_IN_VECTOR_D,
894 				$3->data.itm_exnum);
895 		} else {
896 			TRACE_MESSAGE('y', ("expr: in[expr]\n"));
897 			$$ = expr_unary(ITM_EXPR_IN_VECTOR, $3);
898 		}
899 	}
900 	| ITM_OUTSIZE
901 	{
902 		TRACE_MESSAGE('y', ("expr: outsize\n"));
903 		$$ = expr_self_num(ITM_EXPR_OUT, 0);
904 	}
905 	| ITM_INSIZE
906 	{
907 		TRACE_MESSAGE('y', ("expr: inputsize\n"));
908 		$$ = expr_self_num(ITM_EXPR_IN_VECTOR_D, (size_t)-1);
909 	}
910 	| ITM_TRUE
911 	{
912 		TRACE_MESSAGE('y', ("expr: true\n"));
913 		$$ = expr_self_num(ITM_EXPR_TRUE, 1);
914 	}
915 	| ITM_FALSE
916 	{
917 		TRACE_MESSAGE('y', ("expr: false\n"));
918 		$$ = expr_self_num(ITM_EXPR_FALSE, 0);
919 	}
920 	| itm_in EQ expr
921 	{
922 		TRACE_MESSAGE('y', ("expr: in == expr\n"));
923 		$$ = expr_unary(ITM_EXPR_IN_EQ, $3);
924 	}
925 	| expr EQ itm_in
926 	{
927 		TRACE_MESSAGE('y', ("expr: expr == in\n"));
928 		$$ = expr_unary(ITM_EXPR_IN_EQ, $1);
929 	}
930 	| NOT expr
931 	{
932 		TRACE_MESSAGE('y', ("expr: ! expr\n"));
933 
934 		if (ITM_EXPR_INT == $2->type) {
935 			$$ = expr_self_num(ITM_EXPR_INT, !($2->data.itm_exnum));
936 		} else {
937 			$$ = expr_unary(ITM_EXPR_NOT, $2);
938 		}
939 	}
940 	| NEG expr
941 	{
942 		TRACE_MESSAGE('y', ("expr: ~ expr\n"));
943 		if (ITM_EXPR_INT == $2->type) {
944 			$$ = expr_self_num(ITM_EXPR_INT, ~($2->data.itm_exnum));
945 		} else {
946 			$$ = expr_unary(ITM_EXPR_NEG, $2);
947 		}
948 	}
949 	| MINUS expr %prec MUL
950 	{
951 		TRACE_MESSAGE('y', ("expr: - expr\n"));
952 		if (ITM_EXPR_INT == $2->type) {
953 			$$ = expr_self_num(ITM_EXPR_INT,
954 				(-1) * ($2->data.itm_exnum));
955 		} else {
956 			$$ = expr_unary(ITM_EXPR_UMINUS, $2);
957 		}
958 	}
959 	| expr PLUS expr
960 	{
961 		TRACE_MESSAGE('y', ("expr: expr + expr\n"));
962 		$$ = expr_binary(ITM_EXPR_PLUS, $1, $3);
963 		$1 = expr_seq_to_int($1);
964 		$3 = expr_seq_to_int($3);
965 		switch ($1->type) {
966 		case ITM_EXPR_INT:
967 			switch ($3->type) {
968 			case ITM_EXPR_INT:
969 				$$ = expr_binary2(ITM_EXPR_PLUS_D_D, $1, $3);
970 				break;
971 			case ITM_EXPR_REG:
972 				$$ = expr_binary2(ITM_EXPR_PLUS_D_R, $1, $3);
973 				break;
974 			case ITM_EXPR_IN_VECTOR_D:
975 				$$ = expr_binary2(ITM_EXPR_PLUS_D_INVD, $1, $3);
976 				break;
977 			default:
978 				$$ = expr_binary2(ITM_EXPR_PLUS_D_E, $1, $3);
979 				break;
980 		}
981 			break;
982 		case ITM_EXPR_REG:
983 			switch ($3->type) {
984 			case ITM_EXPR_INT:
985 				$$ = expr_binary2(ITM_EXPR_PLUS_R_D, $1, $3);
986 				break;
987 			case ITM_EXPR_REG:
988 				$$ = expr_binary2(ITM_EXPR_PLUS_R_R, $1, $3);
989 				break;
990 			case ITM_EXPR_IN_VECTOR_D:
991 				$$ = expr_binary2(ITM_EXPR_PLUS_R_INVD, $1, $3);
992 				break;
993 			default:
994 				$$ = expr_binary2(ITM_EXPR_PLUS_R_E, $1, $3);
995 				break;
996 		}
997 			break;
998 		case ITM_EXPR_IN_VECTOR_D:
999 			switch ($3->type) {
1000 			case ITM_EXPR_INT:
1001 				$$ = expr_binary2(ITM_EXPR_PLUS_INVD_D, $1, $3);
1002 				break;
1003 			case ITM_EXPR_REG:
1004 				$$ = expr_binary2(ITM_EXPR_PLUS_INVD_R, $1, $3);
1005 				break;
1006 			case ITM_EXPR_IN_VECTOR_D:
1007 				$$ = expr_binary2(ITM_EXPR_PLUS_INVD_INVD,
1008 					$1, $3);
1009 				break;
1010 			default:
1011 				$$ = expr_binary2(ITM_EXPR_PLUS_INVD_E, $1, $3);
1012 				break;
1013 		}
1014 			break;
1015 		default:
1016 			switch ($3->type) {
1017 			case ITM_EXPR_INT:
1018 				$$ = expr_binary2(ITM_EXPR_PLUS_E_D, $1, $3);
1019 				break;
1020 			case ITM_EXPR_REG:
1021 				$$ = expr_binary2(ITM_EXPR_PLUS_E_R, $1, $3);
1022 				break;
1023 			case ITM_EXPR_IN_VECTOR_D:
1024 				$$ = expr_binary2(ITM_EXPR_PLUS_E_INVD, $1, $3);
1025 				break;
1026 			default:
1027 				$$ = expr_binary2(ITM_EXPR_PLUS, $1, $3);
1028 				break;
1029 			}
1030 			break;
1031 		}
1032 	}
1033 	| expr MINUS expr
1034 	{
1035 		TRACE_MESSAGE('y', ("expr: expr - expr\n"));
1036 		$$ = expr_binary(ITM_EXPR_MINUS, $1, $3);
1037 		$1 = expr_seq_to_int($1);
1038 		$3 = expr_seq_to_int($3);
1039 		switch ($1->type) {
1040 		case ITM_EXPR_INT:
1041 			switch ($3->type) {
1042 			case ITM_EXPR_INT:
1043 				$$ = expr_binary2(ITM_EXPR_MINUS_D_D, $1, $3);
1044 				break;
1045 			case ITM_EXPR_REG:
1046 				$$ = expr_binary2(ITM_EXPR_MINUS_D_R, $1, $3);
1047 				break;
1048 			case ITM_EXPR_IN_VECTOR_D:
1049 				$$ = expr_binary2(ITM_EXPR_MINUS_D_INVD,
1050 					$1, $3);
1051 				break;
1052 			default:
1053 				$$ = expr_binary2(ITM_EXPR_MINUS_D_E, $1, $3);
1054 				break;
1055 			}
1056 			break;
1057 		case ITM_EXPR_REG:
1058 			switch ($3->type) {
1059 			case ITM_EXPR_INT:
1060 				$$ = expr_binary2(ITM_EXPR_MINUS_R_D, $1, $3);
1061 				break;
1062 			case ITM_EXPR_REG:
1063 				$$ = expr_binary2(ITM_EXPR_MINUS_R_R, $1, $3);
1064 				break;
1065 			case ITM_EXPR_IN_VECTOR_D:
1066 				$$ = expr_binary2(ITM_EXPR_MINUS_R_INVD,
1067 					$1, $3);
1068 				break;
1069 			default:
1070 				$$ = expr_binary2(ITM_EXPR_MINUS_R_E, $1, $3);
1071 				break;
1072 			}
1073 			break;
1074 		case ITM_EXPR_IN_VECTOR_D:
1075 			switch ($3->type) {
1076 			case ITM_EXPR_INT:
1077 				$$ = expr_binary2(ITM_EXPR_MINUS_INVD_D,
1078 					$1, $3);
1079 				break;
1080 			case ITM_EXPR_REG:
1081 				$$ = expr_binary2(ITM_EXPR_MINUS_INVD_R,
1082 					$1, $3);
1083 				break;
1084 			case ITM_EXPR_IN_VECTOR_D:
1085 				$$ = expr_binary2(ITM_EXPR_MINUS_INVD_INVD,
1086 					$1, $3);
1087 				break;
1088 			default:
1089 				$$ = expr_binary2(ITM_EXPR_MINUS_INVD_E,
1090 					$1, $3);
1091 				break;
1092 			}
1093 			break;
1094 		default:
1095 			switch ($3->type) {
1096 			case ITM_EXPR_INT:
1097 				$$ = expr_binary2(ITM_EXPR_MINUS_E_D, $1, $3);
1098 				break;
1099 			case ITM_EXPR_REG:
1100 				$$ = expr_binary2(ITM_EXPR_MINUS_E_R, $1, $3);
1101 				break;
1102 			case ITM_EXPR_IN_VECTOR_D:
1103 				$$ = expr_binary2(ITM_EXPR_MINUS_E_INVD,
1104 					$1, $3);
1105 				break;
1106 			default:
1107 				$$ = expr_binary2(ITM_EXPR_MINUS, $1, $3);
1108 				break;
1109 			}
1110 			break;
1111 		}
1112 	}
1113 	| expr MUL expr
1114 	{
1115 		TRACE_MESSAGE('y', ("expr: expr		*expr\n"));
1116 		$$ = expr_binary(ITM_EXPR_MUL, $1, $3);
1117 		$1 = expr_seq_to_int($1);
1118 		$3 = expr_seq_to_int($3);
1119 		switch ($1->type) {
1120 		case ITM_EXPR_INT:
1121 			switch ($3->type) {
1122 			case ITM_EXPR_INT:
1123 				$$ = expr_binary2(ITM_EXPR_MUL_D_D, $1, $3);
1124 				break;
1125 			case ITM_EXPR_REG:
1126 				$$ = expr_binary2(ITM_EXPR_MUL_D_R, $1, $3);
1127 				break;
1128 			case ITM_EXPR_IN_VECTOR_D:
1129 				$$ = expr_binary2(ITM_EXPR_MUL_D_INVD, $1, $3);
1130 				break;
1131 			default:
1132 				$$ = expr_binary2(ITM_EXPR_MUL_D_E, $1, $3);
1133 				break;
1134 			}
1135 			break;
1136 		case ITM_EXPR_REG:
1137 			switch ($3->type) {
1138 			case ITM_EXPR_INT:
1139 				$$ = expr_binary2(ITM_EXPR_MUL_R_D, $1, $3);
1140 				break;
1141 			case ITM_EXPR_REG:
1142 				$$ = expr_binary2(ITM_EXPR_MUL_R_R, $1, $3);
1143 				break;
1144 			case ITM_EXPR_IN_VECTOR_D:
1145 				$$ = expr_binary2(ITM_EXPR_MUL_R_INVD, $1, $3);
1146 				break;
1147 			default:
1148 				$$ = expr_binary2(ITM_EXPR_MUL_R_E, $1, $3);
1149 				break;
1150 			}
1151 			break;
1152 		case ITM_EXPR_IN_VECTOR_D:
1153 			switch ($3->type) {
1154 			case ITM_EXPR_INT:
1155 				$$ = expr_binary2(ITM_EXPR_MUL_INVD_D, $1, $3);
1156 				break;
1157 			case ITM_EXPR_REG:
1158 				$$ = expr_binary2(ITM_EXPR_MUL_INVD_R, $1, $3);
1159 				break;
1160 			case ITM_EXPR_IN_VECTOR_D:
1161 				$$ = expr_binary2(ITM_EXPR_MUL_INVD_INVD,
1162 					$1, $3);
1163 				break;
1164 			default:
1165 				$$ = expr_binary2(ITM_EXPR_MUL_INVD_E, $1, $3);
1166 				break;
1167 			}
1168 			break;
1169 		default:
1170 			switch ($3->type) {
1171 			case ITM_EXPR_INT:
1172 				$$ = expr_binary2(ITM_EXPR_MUL_E_D, $1, $3);
1173 				break;
1174 			case ITM_EXPR_REG:
1175 				$$ = expr_binary2(ITM_EXPR_MUL_E_R, $1, $3);
1176 				break;
1177 			case ITM_EXPR_IN_VECTOR_D:
1178 				$$ = expr_binary2(ITM_EXPR_MUL_E_INVD, $1, $3);
1179 				break;
1180 			default:
1181 				$$ = expr_binary2(ITM_EXPR_MUL, $1, $3);
1182 				break;
1183 			}
1184 			break;
1185 		}
1186 	}
1187 	| expr DIV expr
1188 	{
1189 		TRACE_MESSAGE('y', ("expr: expr / expr\n"));
1190 		$$ = expr_binary(ITM_EXPR_DIV, $1, $3);
1191 		$1 = expr_seq_to_int($1);
1192 		$3 = expr_seq_to_int($3);
1193 		switch ($1->type) {
1194 		case ITM_EXPR_INT:
1195 			switch ($3->type) {
1196 			case ITM_EXPR_INT:
1197 				$$ = expr_binary2(ITM_EXPR_DIV_D_D, $1, $3);
1198 				break;
1199 			case ITM_EXPR_REG:
1200 				$$ = expr_binary2(ITM_EXPR_DIV_D_R, $1, $3);
1201 				break;
1202 			case ITM_EXPR_IN_VECTOR_D:
1203 				$$ = expr_binary2(ITM_EXPR_DIV_D_INVD, $1, $3);
1204 				break;
1205 			default:
1206 				$$ = expr_binary2(ITM_EXPR_DIV_D_E, $1, $3);
1207 				break;
1208 			}
1209 			break;
1210 		case ITM_EXPR_REG:
1211 			switch ($3->type) {
1212 			case ITM_EXPR_INT:
1213 				$$ = expr_binary2(ITM_EXPR_DIV_R_D, $1, $3);
1214 				break;
1215 			case ITM_EXPR_REG:
1216 				$$ = expr_binary2(ITM_EXPR_DIV_R_R, $1, $3);
1217 				break;
1218 			case ITM_EXPR_IN_VECTOR_D:
1219 				$$ = expr_binary2(ITM_EXPR_DIV_R_INVD, $1, $3);
1220 				break;
1221 			default:
1222 				$$ = expr_binary2(ITM_EXPR_DIV_R_E, $1, $3);
1223 				break;
1224 			}
1225 			break;
1226 		case ITM_EXPR_IN_VECTOR_D:
1227 			switch ($3->type) {
1228 			case ITM_EXPR_INT:
1229 				$$ = expr_binary2(ITM_EXPR_DIV_INVD_D, $1, $3);
1230 				break;
1231 			case ITM_EXPR_REG:
1232 				$$ = expr_binary2(ITM_EXPR_DIV_INVD_R, $1, $3);
1233 				break;
1234 			case ITM_EXPR_IN_VECTOR_D:
1235 				$$ = expr_binary2(ITM_EXPR_DIV_INVD_INVD,
1236 					$1, $3);
1237 				break;
1238 			default:
1239 				$$ = expr_binary2(ITM_EXPR_DIV_INVD_E, $1, $3);
1240 				break;
1241 			}
1242 			break;
1243 		default:
1244 			switch ($3->type) {
1245 			case ITM_EXPR_INT:
1246 				$$ = expr_binary2(ITM_EXPR_DIV_E_D, $1, $3);
1247 				break;
1248 			case ITM_EXPR_REG:
1249 				$$ = expr_binary2(ITM_EXPR_DIV_E_R, $1, $3);
1250 				break;
1251 			case ITM_EXPR_IN_VECTOR_D:
1252 				$$ = expr_binary2(ITM_EXPR_DIV_E_INVD, $1, $3);
1253 				break;
1254 			default:
1255 				$$ = expr_binary2(ITM_EXPR_DIV, $1, $3);
1256 				break;
1257 			}
1258 			break;
1259 		}
1260 	}
1261 	| expr MOD expr
1262 	{
1263 		TRACE_MESSAGE('y', ("expr: expr % expr\n"));
1264 		$$ = expr_binary(ITM_EXPR_MOD, $1, $3);
1265 		$1 = expr_seq_to_int($1);
1266 		$3 = expr_seq_to_int($3);
1267 		switch ($1->type) {
1268 		case ITM_EXPR_INT:
1269 			switch ($3->type) {
1270 			case ITM_EXPR_INT:
1271 				$$ = expr_binary2(ITM_EXPR_MOD_D_D, $1, $3);
1272 				break;
1273 			case ITM_EXPR_REG:
1274 				$$ = expr_binary2(ITM_EXPR_MOD_D_R, $1, $3);
1275 				break;
1276 			case ITM_EXPR_IN_VECTOR_D:
1277 				$$ = expr_binary2(ITM_EXPR_MOD_D_INVD, $1, $3);
1278 				break;
1279 			default:
1280 				$$ = expr_binary2(ITM_EXPR_MOD_D_E, $1, $3);
1281 				break;
1282 			}
1283 			break;
1284 		case ITM_EXPR_REG:
1285 			switch ($3->type) {
1286 			case ITM_EXPR_INT:
1287 				$$ = expr_binary2(ITM_EXPR_MOD_R_D, $1, $3);
1288 				break;
1289 			case ITM_EXPR_REG:
1290 				$$ = expr_binary2(ITM_EXPR_MOD_R_R, $1, $3);
1291 				break;
1292 			case ITM_EXPR_IN_VECTOR_D:
1293 				$$ = expr_binary2(ITM_EXPR_MOD_R_INVD, $1, $3);
1294 				break;
1295 			default:
1296 				$$ = expr_binary2(ITM_EXPR_MOD_R_E, $1, $3);
1297 				break;
1298 			}
1299 			break;
1300 		case ITM_EXPR_IN_VECTOR_D:
1301 			switch ($3->type) {
1302 			case ITM_EXPR_INT:
1303 				$$ = expr_binary2(ITM_EXPR_MOD_INVD_D, $1, $3);
1304 				break;
1305 			case ITM_EXPR_REG:
1306 				$$ = expr_binary2(ITM_EXPR_MOD_INVD_R, $1, $3);
1307 				break;
1308 			case ITM_EXPR_IN_VECTOR_D:
1309 				$$ = expr_binary2(ITM_EXPR_MOD_INVD_INVD,
1310 					$1, $3);
1311 				break;
1312 			default:
1313 				$$ = expr_binary2(ITM_EXPR_MOD_INVD_E, $1, $3);
1314 				break;
1315 			}
1316 			break;
1317 		default:
1318 			switch ($3->type) {
1319 			case ITM_EXPR_INT:
1320 				$$ = expr_binary2(ITM_EXPR_MOD_E_D, $1, $3);
1321 				break;
1322 			case ITM_EXPR_REG:
1323 				$$ = expr_binary2(ITM_EXPR_MOD_E_R, $1, $3);
1324 				break;
1325 			case ITM_EXPR_IN_VECTOR_D:
1326 				$$ = expr_binary2(ITM_EXPR_MOD_E_INVD, $1, $3);
1327 				break;
1328 			default:
1329 				$$ = expr_binary2(ITM_EXPR_MOD, $1, $3);
1330 				break;
1331 			}
1332 			break;
1333 		}
1334 	}
1335 	| expr SHL expr
1336 	{
1337 		TRACE_MESSAGE('y', ("expr: expr << expr\n"));
1338 		$$ = expr_binary(ITM_EXPR_SHIFT_L, $1, $3);
1339 		$1 = expr_seq_to_int($1);
1340 		$3 = expr_seq_to_int($3);
1341 		switch ($1->type) {
1342 		case ITM_EXPR_INT:
1343 			switch ($3->type) {
1344 			case ITM_EXPR_INT:
1345 				$$ = expr_binary2(ITM_EXPR_SHIFT_L_D_D, $1, $3);
1346 				break;
1347 			case ITM_EXPR_REG:
1348 				$$ = expr_binary2(ITM_EXPR_SHIFT_L_D_R, $1, $3);
1349 				break;
1350 			case ITM_EXPR_IN_VECTOR_D:
1351 				$$ = expr_binary2(ITM_EXPR_SHIFT_L_D_INVD,
1352 					$1, $3);
1353 				break;
1354 			default:
1355 				$$ = expr_binary2(ITM_EXPR_SHIFT_L_D_E, $1, $3);
1356 				break;
1357 			}
1358 			break;
1359 		case ITM_EXPR_REG:
1360 			switch ($3->type) {
1361 			case ITM_EXPR_INT:
1362 				$$ = expr_binary2(ITM_EXPR_SHIFT_L_R_D, $1, $3);
1363 				break;
1364 			case ITM_EXPR_REG:
1365 				$$ = expr_binary2(ITM_EXPR_SHIFT_L_R_R, $1, $3);
1366 				break;
1367 			case ITM_EXPR_IN_VECTOR_D:
1368 				$$ = expr_binary2(ITM_EXPR_SHIFT_L_R_INVD,
1369 					$1, $3);
1370 				break;
1371 			default:
1372 				$$ = expr_binary2(ITM_EXPR_SHIFT_L_R_E, $1, $3);
1373 				break;
1374 			}
1375 			break;
1376 		case ITM_EXPR_IN_VECTOR_D:
1377 			switch ($3->type) {
1378 			case ITM_EXPR_INT:
1379 				$$ = expr_binary2(ITM_EXPR_SHIFT_L_INVD_D,
1380 					$1, $3);
1381 				break;
1382 			case ITM_EXPR_REG:
1383 				$$ = expr_binary2(ITM_EXPR_SHIFT_L_INVD_R,
1384 					$1, $3);
1385 				break;
1386 			case ITM_EXPR_IN_VECTOR_D:
1387 				$$ = expr_binary2(ITM_EXPR_SHIFT_L_INVD_INVD,
1388 					$1, $3);
1389 				break;
1390 			default:
1391 				$$ = expr_binary2(ITM_EXPR_SHIFT_L_INVD_E,
1392 					$1, $3);
1393 				break;
1394 			}
1395 			break;
1396 		default:
1397 			switch ($3->type) {
1398 			case ITM_EXPR_INT:
1399 				$$ = expr_binary2(ITM_EXPR_SHIFT_L_E_D, $1, $3);
1400 				break;
1401 			case ITM_EXPR_REG:
1402 				$$ = expr_binary2(ITM_EXPR_SHIFT_L_E_R, $1, $3);
1403 				break;
1404 			case ITM_EXPR_IN_VECTOR_D:
1405 				$$ = expr_binary2(ITM_EXPR_SHIFT_L_E_INVD,
1406 					$1, $3);
1407 				break;
1408 			default:
1409 				$$ = expr_binary2(ITM_EXPR_SHIFT_L, $1, $3);
1410 				break;
1411 			}
1412 			break;
1413 		}
1414 	}
1415 	| expr SHR expr
1416 	{
1417 		TRACE_MESSAGE('y', ("expr: expr >> expr\n"));
1418 		$$ = expr_binary(ITM_EXPR_SHIFT_R, $1, $3);
1419 		$1 = expr_seq_to_int($1);
1420 		$3 = expr_seq_to_int($3);
1421 		switch ($1->type) {
1422 		case ITM_EXPR_INT:
1423 			switch ($3->type) {
1424 			case ITM_EXPR_INT:
1425 				$$ = expr_binary2(ITM_EXPR_SHIFT_R_D_D, $1, $3);
1426 				break;
1427 			case ITM_EXPR_REG:
1428 				$$ = expr_binary2(ITM_EXPR_SHIFT_R_D_R, $1, $3);
1429 				break;
1430 			case ITM_EXPR_IN_VECTOR_D:
1431 				$$ = expr_binary2(ITM_EXPR_SHIFT_R_D_INVD,
1432 					$1, $3);
1433 				break;
1434 			default:
1435 				$$ = expr_binary2(ITM_EXPR_SHIFT_R_D_E, $1, $3);
1436 				break;
1437 			}
1438 			break;
1439 		case ITM_EXPR_REG:
1440 			switch ($3->type) {
1441 			case ITM_EXPR_INT:
1442 				$$ = expr_binary2(ITM_EXPR_SHIFT_R_R_D, $1, $3);
1443 				break;
1444 			case ITM_EXPR_REG:
1445 				$$ = expr_binary2(ITM_EXPR_SHIFT_R_R_R, $1, $3);
1446 				break;
1447 			case ITM_EXPR_IN_VECTOR_D:
1448 				$$ = expr_binary2(ITM_EXPR_SHIFT_R_R_INVD,
1449 					$1, $3);
1450 				break;
1451 			default:
1452 				$$ = expr_binary2(ITM_EXPR_SHIFT_R_R_E, $1, $3);
1453 				break;
1454 			}
1455 			break;
1456 		case ITM_EXPR_IN_VECTOR_D:
1457 			switch ($3->type) {
1458 			case ITM_EXPR_INT:
1459 				$$ = expr_binary2(ITM_EXPR_SHIFT_R_INVD_D,
1460 					$1, $3);
1461 				break;
1462 			case ITM_EXPR_REG:
1463 				$$ = expr_binary2(ITM_EXPR_SHIFT_R_INVD_R,
1464 					$1, $3);
1465 				break;
1466 			case ITM_EXPR_IN_VECTOR_D:
1467 				$$ = expr_binary2(ITM_EXPR_SHIFT_R_INVD_INVD,
1468 					$1, $3);
1469 				break;
1470 			default:
1471 				$$ = expr_binary2(ITM_EXPR_SHIFT_R_INVD_E,
1472 					$1, $3);
1473 				break;
1474 			}
1475 			break;
1476 		default:
1477 			switch ($3->type) {
1478 			case ITM_EXPR_INT:
1479 				$$ = expr_binary2(ITM_EXPR_SHIFT_R_E_D, $1, $3);
1480 				break;
1481 			case ITM_EXPR_REG:
1482 				$$ = expr_binary2(ITM_EXPR_SHIFT_R_E_R, $1, $3);
1483 				break;
1484 			case ITM_EXPR_IN_VECTOR_D:
1485 				$$ = expr_binary2(ITM_EXPR_SHIFT_R_E_INVD,
1486 					$1, $3);
1487 				break;
1488 			default:
1489 				$$ = expr_binary2(ITM_EXPR_SHIFT_R, $1, $3);
1490 				break;
1491 			}
1492 			break;
1493 		}
1494 	}
1495 	| expr OR expr
1496 	{
1497 		TRACE_MESSAGE('y', ("expr: expr | expr\n"));
1498 		$$ = expr_binary(ITM_EXPR_OR, $1, $3);
1499 		$1 = expr_seq_to_int($1);
1500 		$3 = expr_seq_to_int($3);
1501 		switch ($1->type) {
1502 		case ITM_EXPR_INT:
1503 			switch ($3->type) {
1504 			case ITM_EXPR_INT:
1505 				$$ = expr_binary2(ITM_EXPR_OR_D_D, $1, $3);
1506 				break;
1507 			case ITM_EXPR_REG:
1508 				$$ = expr_binary2(ITM_EXPR_OR_D_R, $1, $3);
1509 				break;
1510 			case ITM_EXPR_IN_VECTOR_D:
1511 				$$ = expr_binary2(ITM_EXPR_OR_D_INVD, $1, $3);
1512 				break;
1513 			default:
1514 				$$ = expr_binary2(ITM_EXPR_OR_D_E, $1, $3);
1515 				break;
1516 			}
1517 			break;
1518 		case ITM_EXPR_REG:
1519 			switch ($3->type) {
1520 			case ITM_EXPR_INT:
1521 				$$ = expr_binary2(ITM_EXPR_OR_R_D, $1, $3);
1522 				break;
1523 			case ITM_EXPR_REG:
1524 				$$ = expr_binary2(ITM_EXPR_OR_R_R, $1, $3);
1525 				break;
1526 			case ITM_EXPR_IN_VECTOR_D:
1527 				$$ = expr_binary2(ITM_EXPR_OR_R_INVD, $1, $3);
1528 				break;
1529 			default:
1530 				$$ = expr_binary2(ITM_EXPR_OR_R_E, $1, $3);
1531 				break;
1532 			}
1533 			break;
1534 		case ITM_EXPR_IN_VECTOR_D:
1535 			switch ($3->type) {
1536 			case ITM_EXPR_INT:
1537 				$$ = expr_binary2(ITM_EXPR_OR_INVD_D, $1, $3);
1538 				break;
1539 			case ITM_EXPR_REG:
1540 				$$ = expr_binary2(ITM_EXPR_OR_INVD_R, $1, $3);
1541 				break;
1542 			case ITM_EXPR_IN_VECTOR_D:
1543 				$$ = expr_binary2(ITM_EXPR_OR_INVD_INVD,
1544 					$1, $3);
1545 				break;
1546 			default:
1547 				$$ = expr_binary2(ITM_EXPR_OR_INVD_E, $1, $3);
1548 				break;
1549 			}
1550 			break;
1551 		default:
1552 			switch ($3->type) {
1553 			case ITM_EXPR_INT:
1554 				$$ = expr_binary2(ITM_EXPR_OR_E_D, $1, $3);
1555 				break;
1556 			case ITM_EXPR_REG:
1557 				$$ = expr_binary2(ITM_EXPR_OR_E_R, $1, $3);
1558 				break;
1559 			case ITM_EXPR_IN_VECTOR_D:
1560 				$$ = expr_binary2(ITM_EXPR_OR_E_INVD, $1, $3);
1561 				break;
1562 			default:
1563 				$$ = expr_binary2(ITM_EXPR_OR, $1, $3);
1564 				break;
1565 			}
1566 			break;
1567 		}
1568 	}
1569 	| expr XOR expr
1570 	{
1571 		TRACE_MESSAGE('y', ("expr: expr ^ expr\n"));
1572 		$$ = expr_binary(ITM_EXPR_XOR, $1, $3);
1573 		$1 = expr_seq_to_int($1);
1574 		$3 = expr_seq_to_int($3);
1575 		switch ($1->type) {
1576 		case ITM_EXPR_INT:
1577 			switch ($3->type) {
1578 			case ITM_EXPR_INT:
1579 				$$ = expr_binary2(ITM_EXPR_XOR_D_D, $1, $3);
1580 				break;
1581 			case ITM_EXPR_REG:
1582 				$$ = expr_binary2(ITM_EXPR_XOR_D_R, $1, $3);
1583 				break;
1584 			case ITM_EXPR_IN_VECTOR_D:
1585 				$$ = expr_binary2(ITM_EXPR_XOR_D_INVD, $1, $3);
1586 				break;
1587 			default:
1588 				$$ = expr_binary2(ITM_EXPR_XOR_D_E, $1, $3);
1589 				break;
1590 			}
1591 			break;
1592 		case ITM_EXPR_REG:
1593 			switch ($3->type) {
1594 			case ITM_EXPR_INT:
1595 				$$ = expr_binary2(ITM_EXPR_XOR_R_D, $1, $3);
1596 				break;
1597 			case ITM_EXPR_REG:
1598 				$$ = expr_binary2(ITM_EXPR_XOR_R_R, $1, $3);
1599 				break;
1600 			case ITM_EXPR_IN_VECTOR_D:
1601 				$$ = expr_binary2(ITM_EXPR_XOR_R_INVD, $1, $3);
1602 				break;
1603 			default:
1604 				$$ = expr_binary2(ITM_EXPR_XOR_R_E, $1, $3);
1605 				break;
1606 			}
1607 			break;
1608 		case ITM_EXPR_IN_VECTOR_D:
1609 			switch ($3->type) {
1610 			case ITM_EXPR_INT:
1611 				$$ = expr_binary2(ITM_EXPR_XOR_INVD_D, $1, $3);
1612 				break;
1613 			case ITM_EXPR_REG:
1614 				$$ = expr_binary2(ITM_EXPR_XOR_INVD_R, $1, $3);
1615 				break;
1616 			case ITM_EXPR_IN_VECTOR_D:
1617 				$$ = expr_binary2(ITM_EXPR_XOR_INVD_INVD,
1618 					$1, $3);
1619 				break;
1620 			default:
1621 				$$ = expr_binary2(ITM_EXPR_XOR_INVD_E, $1, $3);
1622 				break;
1623 			}
1624 			break;
1625 		default:
1626 			switch ($3->type) {
1627 			case ITM_EXPR_INT:
1628 				$$ = expr_binary2(ITM_EXPR_XOR_E_D, $1, $3);
1629 				break;
1630 			case ITM_EXPR_REG:
1631 				$$ = expr_binary2(ITM_EXPR_XOR_E_R, $1, $3);
1632 				break;
1633 			case ITM_EXPR_IN_VECTOR_D:
1634 				$$ = expr_binary2(ITM_EXPR_XOR_E_INVD, $1, $3);
1635 				break;
1636 			default:
1637 				$$ = expr_binary2(ITM_EXPR_XOR, $1, $3);
1638 				break;
1639 			}
1640 			break;
1641 		}
1642 	}
1643 	| expr AND expr
1644 	{
1645 		TRACE_MESSAGE('y', ("expr: expr & expr\n"));
1646 		$$ = expr_binary(ITM_EXPR_AND, $1, $3);
1647 		$1 = expr_seq_to_int($1);
1648 		$3 = expr_seq_to_int($3);
1649 		switch ($1->type) {
1650 		case ITM_EXPR_INT:
1651 			switch ($3->type) {
1652 			case ITM_EXPR_INT:
1653 				$$ = expr_binary2(ITM_EXPR_AND_D_D, $1, $3);
1654 				break;
1655 			case ITM_EXPR_REG:
1656 				$$ = expr_binary2(ITM_EXPR_AND_D_R, $1, $3);
1657 				break;
1658 			case ITM_EXPR_IN_VECTOR_D:
1659 				$$ = expr_binary2(ITM_EXPR_AND_D_INVD, $1, $3);
1660 				break;
1661 			default:
1662 				$$ = expr_binary2(ITM_EXPR_AND_D_E, $1, $3);
1663 				break;
1664 	}
1665 			break;
1666 		case ITM_EXPR_REG:
1667 			switch ($3->type) {
1668 			case ITM_EXPR_INT:
1669 				$$ = expr_binary2(ITM_EXPR_AND_R_D, $1, $3);
1670 				break;
1671 			case ITM_EXPR_REG:
1672 				$$ = expr_binary2(ITM_EXPR_AND_R_R, $1, $3);
1673 				break;
1674 			case ITM_EXPR_IN_VECTOR_D:
1675 				$$ = expr_binary2(ITM_EXPR_AND_R_INVD, $1, $3);
1676 				break;
1677 			default:
1678 				$$ = expr_binary2(ITM_EXPR_AND_R_E, $1, $3);
1679 				break;
1680 			}
1681 			break;
1682 		case ITM_EXPR_IN_VECTOR_D:
1683 			switch ($3->type) {
1684 			case ITM_EXPR_INT:
1685 				$$ = expr_binary2(ITM_EXPR_AND_INVD_D, $1, $3);
1686 				break;
1687 			case ITM_EXPR_REG:
1688 				$$ = expr_binary2(ITM_EXPR_AND_INVD_R, $1, $3);
1689 				break;
1690 			case ITM_EXPR_IN_VECTOR_D:
1691 				$$ = expr_binary2(ITM_EXPR_AND_INVD_INVD,
1692 					$1, $3);
1693 				break;
1694 			default:
1695 				$$ = expr_binary2(ITM_EXPR_AND_INVD_E, $1, $3);
1696 				break;
1697 			}
1698 			break;
1699 		default:
1700 			switch ($3->type) {
1701 			case ITM_EXPR_INT:
1702 				$$ = expr_binary2(ITM_EXPR_AND_E_D, $1, $3);
1703 				break;
1704 			case ITM_EXPR_REG:
1705 				$$ = expr_binary2(ITM_EXPR_AND_E_R, $1, $3);
1706 				break;
1707 			case ITM_EXPR_IN_VECTOR_D:
1708 				$$ = expr_binary2(ITM_EXPR_AND_E_INVD, $1, $3);
1709 				break;
1710 			default:
1711 				$$ = expr_binary2(ITM_EXPR_AND, $1, $3);
1712 				break;
1713 			}
1714 			break;
1715 		}
1716 	}
1717 	| expr EQ expr
1718 	{
1719 		TRACE_MESSAGE('y', ("expr: expr == expr\n"));
1720 		$$ = expr_binary(ITM_EXPR_EQ, $1, $3);
1721 		$1 = expr_seq_to_int($1);
1722 		$3 = expr_seq_to_int($3);
1723 		switch ($1->type) {
1724 		case ITM_EXPR_INT:
1725 			switch ($3->type) {
1726 			case ITM_EXPR_INT:
1727 				$$ = expr_binary2(ITM_EXPR_EQ_D_D, $1, $3);
1728 				break;
1729 			case ITM_EXPR_REG:
1730 				$$ = expr_binary2(ITM_EXPR_EQ_D_R, $1, $3);
1731 				break;
1732 			case ITM_EXPR_IN_VECTOR_D:
1733 				$$ = expr_binary2(ITM_EXPR_EQ_D_INVD, $1, $3);
1734 				break;
1735 			default:
1736 				$$ = expr_binary2(ITM_EXPR_EQ_D_E, $1, $3);
1737 				break;
1738 			}
1739 			break;
1740 		case ITM_EXPR_REG:
1741 			switch ($3->type) {
1742 			case ITM_EXPR_INT:
1743 				$$ = expr_binary2(ITM_EXPR_EQ_R_D, $1, $3);
1744 				break;
1745 			case ITM_EXPR_REG:
1746 				$$ = expr_binary2(ITM_EXPR_EQ_R_R, $1, $3);
1747 				break;
1748 			case ITM_EXPR_IN_VECTOR_D:
1749 				$$ = expr_binary2(ITM_EXPR_EQ_R_INVD, $1, $3);
1750 				break;
1751 			default:
1752 				$$ = expr_binary2(ITM_EXPR_EQ_R_E, $1, $3);
1753 				break;
1754 			}
1755 			break;
1756 		case ITM_EXPR_IN_VECTOR_D:
1757 			switch ($3->type) {
1758 			case ITM_EXPR_INT:
1759 				$$ = expr_binary2(ITM_EXPR_EQ_INVD_D, $1, $3);
1760 				break;
1761 			case ITM_EXPR_REG:
1762 				$$ = expr_binary2(ITM_EXPR_EQ_INVD_R, $1, $3);
1763 				break;
1764 			case ITM_EXPR_IN_VECTOR_D:
1765 				$$ = expr_binary2(ITM_EXPR_EQ_INVD_INVD,
1766 					$1, $3);
1767 				break;
1768 			default:
1769 				$$ = expr_binary2(ITM_EXPR_EQ_INVD_E, $1, $3);
1770 				break;
1771 			}
1772 			break;
1773 		default:
1774 			switch ($3->type) {
1775 			case ITM_EXPR_INT:
1776 				$$ = expr_binary2(ITM_EXPR_EQ_E_D, $1, $3);
1777 				break;
1778 			case ITM_EXPR_REG:
1779 				$$ = expr_binary2(ITM_EXPR_EQ_E_R, $1, $3);
1780 				break;
1781 			case ITM_EXPR_IN_VECTOR_D:
1782 				$$ = expr_binary2(ITM_EXPR_EQ_E_INVD, $1, $3);
1783 				break;
1784 			default:
1785 				$$ = expr_binary2(ITM_EXPR_EQ, $1, $3);
1786 				break;
1787 			}
1788 			break;
1789 		}
1790 	}
1791 	| expr NE expr
1792 	{
1793 		TRACE_MESSAGE('y', ("expr: expr != expr\n"));
1794 		$$ = expr_binary(ITM_EXPR_NE, $1, $3);
1795 		$1 = expr_seq_to_int($1);
1796 		$3 = expr_seq_to_int($3);
1797 		switch ($1->type) {
1798 		case ITM_EXPR_INT:
1799 			switch ($3->type) {
1800 			case ITM_EXPR_INT:
1801 				$$ = expr_binary2(ITM_EXPR_NE_D_D, $1, $3);
1802 				break;
1803 			case ITM_EXPR_REG:
1804 				$$ = expr_binary2(ITM_EXPR_NE_D_R, $1, $3);
1805 				break;
1806 			case ITM_EXPR_IN_VECTOR_D:
1807 				$$ = expr_binary2(ITM_EXPR_NE_D_INVD, $1, $3);
1808 				break;
1809 			default:
1810 				$$ = expr_binary2(ITM_EXPR_NE_D_E, $1, $3);
1811 				break;
1812 			}
1813 			break;
1814 		case ITM_EXPR_REG:
1815 			switch ($3->type) {
1816 			case ITM_EXPR_INT:
1817 				$$ = expr_binary2(ITM_EXPR_NE_R_D, $1, $3);
1818 				break;
1819 			case ITM_EXPR_REG:
1820 				$$ = expr_binary2(ITM_EXPR_NE_R_R, $1, $3);
1821 				break;
1822 			case ITM_EXPR_IN_VECTOR_D:
1823 				$$ = expr_binary2(ITM_EXPR_NE_R_INVD, $1, $3);
1824 				break;
1825 			default:
1826 				$$ = expr_binary2(ITM_EXPR_NE_R_E, $1, $3);
1827 				break;
1828 			}
1829 			break;
1830 		case ITM_EXPR_IN_VECTOR_D:
1831 			switch ($3->type) {
1832 			case ITM_EXPR_INT:
1833 				$$ = expr_binary2(ITM_EXPR_NE_INVD_D, $1, $3);
1834 				break;
1835 			case ITM_EXPR_REG:
1836 				$$ = expr_binary2(ITM_EXPR_NE_INVD_R, $1, $3);
1837 				break;
1838 			case ITM_EXPR_IN_VECTOR_D:
1839 				$$ = expr_binary2(ITM_EXPR_NE_INVD_INVD,
1840 					$1, $3);
1841 				break;
1842 			default:
1843 				$$ = expr_binary2(ITM_EXPR_NE_INVD_E, $1, $3);
1844 				break;
1845 			}
1846 			break;
1847 		default:
1848 			switch ($3->type) {
1849 			case ITM_EXPR_INT:
1850 				$$ = expr_binary2(ITM_EXPR_NE_E_D, $1, $3);
1851 				break;
1852 			case ITM_EXPR_REG:
1853 				$$ = expr_binary2(ITM_EXPR_NE_E_R, $1, $3);
1854 				break;
1855 			case ITM_EXPR_IN_VECTOR_D:
1856 				$$ = expr_binary2(ITM_EXPR_NE_E_INVD, $1, $3);
1857 				break;
1858 			default:
1859 				$$ = expr_binary2(ITM_EXPR_NE, $1, $3);
1860 				break;
1861 			}
1862 			break;
1863 		}
1864 	}
1865 	| expr GT  expr
1866 	{
1867 		TRACE_MESSAGE('y', ("expr: expr > expr\n"));
1868 		$$ = expr_binary(ITM_EXPR_GT, $1, $3);
1869 		$1 = expr_seq_to_int($1);
1870 		$3 = expr_seq_to_int($3);
1871 		switch ($1->type) {
1872 		case ITM_EXPR_INT:
1873 			switch ($3->type) {
1874 			case ITM_EXPR_INT:
1875 				$$ = expr_binary2(ITM_EXPR_GT_D_D, $1, $3);
1876 				break;
1877 			case ITM_EXPR_REG:
1878 				$$ = expr_binary2(ITM_EXPR_GT_D_R, $1, $3);
1879 				break;
1880 			case ITM_EXPR_IN_VECTOR_D:
1881 				$$ = expr_binary2(ITM_EXPR_GT_D_INVD, $1, $3);
1882 				break;
1883 			default:
1884 				$$ = expr_binary2(ITM_EXPR_GT_D_E, $1, $3);
1885 				break;
1886 			}
1887 			break;
1888 		case ITM_EXPR_REG:
1889 			switch ($3->type) {
1890 			case ITM_EXPR_INT:
1891 				$$ = expr_binary2(ITM_EXPR_GT_R_D, $1, $3);
1892 				break;
1893 			case ITM_EXPR_REG:
1894 				$$ = expr_binary2(ITM_EXPR_GT_R_R, $1, $3);
1895 				break;
1896 			case ITM_EXPR_IN_VECTOR_D:
1897 				$$ = expr_binary2(ITM_EXPR_GT_R_INVD, $1, $3);
1898 				break;
1899 			default:
1900 				$$ = expr_binary2(ITM_EXPR_GT_R_E, $1, $3);
1901 				break;
1902 			}
1903 			break;
1904 		case ITM_EXPR_IN_VECTOR_D:
1905 			switch ($3->type) {
1906 			case ITM_EXPR_INT:
1907 				$$ = expr_binary2(ITM_EXPR_GT_INVD_D, $1, $3);
1908 				break;
1909 			case ITM_EXPR_REG:
1910 				$$ = expr_binary2(ITM_EXPR_GT_INVD_R, $1, $3);
1911 				break;
1912 			case ITM_EXPR_IN_VECTOR_D:
1913 				$$ = expr_binary2(ITM_EXPR_GT_INVD_INVD,
1914 					$1, $3);
1915 				break;
1916 			default:
1917 				$$ = expr_binary2(ITM_EXPR_GT_INVD_E, $1, $3);
1918 				break;
1919 			}
1920 			break;
1921 		default:
1922 			switch ($3->type) {
1923 			case ITM_EXPR_INT:
1924 				$$ = expr_binary2(ITM_EXPR_GT_E_D, $1, $3);
1925 				break;
1926 			case ITM_EXPR_REG:
1927 				$$ = expr_binary2(ITM_EXPR_GT_E_R, $1, $3);
1928 				break;
1929 			case ITM_EXPR_IN_VECTOR_D:
1930 				$$ = expr_binary2(ITM_EXPR_GT_E_INVD, $1, $3);
1931 				break;
1932 			default:
1933 				$$ = expr_binary2(ITM_EXPR_GT, $1, $3);
1934 				break;
1935 			}
1936 			break;
1937 		}
1938 	}
1939 	| expr GE  expr
1940 	{
1941 		TRACE_MESSAGE('y', ("expr: expr >= expr\n"));
1942 		$$ = expr_binary(ITM_EXPR_GE, $1, $3);
1943 		$1 = expr_seq_to_int($1);
1944 		$3 = expr_seq_to_int($3);
1945 		switch ($1->type) {
1946 		case ITM_EXPR_INT:
1947 			switch ($3->type) {
1948 			case ITM_EXPR_INT:
1949 				$$ = expr_binary2(ITM_EXPR_GE_D_D, $1, $3);
1950 				break;
1951 			case ITM_EXPR_REG:
1952 				$$ = expr_binary2(ITM_EXPR_GE_D_R, $1, $3);
1953 				break;
1954 			case ITM_EXPR_IN_VECTOR_D:
1955 				$$ = expr_binary2(ITM_EXPR_GE_D_INVD, $1, $3);
1956 				break;
1957 			default:
1958 				$$ = expr_binary2(ITM_EXPR_GE_D_E, $1, $3);
1959 				break;
1960 			}
1961 			break;
1962 		case ITM_EXPR_REG:
1963 			switch ($3->type) {
1964 			case ITM_EXPR_INT:
1965 				$$ = expr_binary2(ITM_EXPR_GE_R_D, $1, $3);
1966 				break;
1967 			case ITM_EXPR_REG:
1968 				$$ = expr_binary2(ITM_EXPR_GE_R_R, $1, $3);
1969 				break;
1970 			case ITM_EXPR_IN_VECTOR_D:
1971 				$$ = expr_binary2(ITM_EXPR_GE_R_INVD, $1, $3);
1972 				break;
1973 			default:
1974 				$$ = expr_binary2(ITM_EXPR_GE_R_E, $1, $3);
1975 				break;
1976 			}
1977 			break;
1978 		case ITM_EXPR_IN_VECTOR_D:
1979 			switch ($3->type) {
1980 			case ITM_EXPR_INT:
1981 				$$ = expr_binary2(ITM_EXPR_GE_INVD_D, $1, $3);
1982 				break;
1983 			case ITM_EXPR_REG:
1984 				$$ = expr_binary2(ITM_EXPR_GE_INVD_R, $1, $3);
1985 				break;
1986 			case ITM_EXPR_IN_VECTOR_D:
1987 				$$ = expr_binary2(ITM_EXPR_GE_INVD_INVD,
1988 					$1, $3);
1989 				break;
1990 			default:
1991 				$$ = expr_binary2(ITM_EXPR_GE_INVD_E, $1, $3);
1992 				break;
1993 			}
1994 			break;
1995 		default:
1996 			switch ($3->type) {
1997 			case ITM_EXPR_INT:
1998 				$$ = expr_binary2(ITM_EXPR_GE_E_D, $1, $3);
1999 				break;
2000 			case ITM_EXPR_REG:
2001 				$$ = expr_binary2(ITM_EXPR_GE_E_R, $1, $3);
2002 				break;
2003 			case ITM_EXPR_IN_VECTOR_D:
2004 				$$ = expr_binary2(ITM_EXPR_GE_E_INVD, $1, $3);
2005 				break;
2006 			default:
2007 				$$ = expr_binary2(ITM_EXPR_GE, $1, $3);
2008 				break;
2009 			}
2010 			break;
2011 		}
2012 	}
2013 	| expr LT  expr
2014 	{
2015 		TRACE_MESSAGE('y', ("expr: expr < expr\n"));
2016 		$$ = expr_binary(ITM_EXPR_LT, $1, $3);
2017 		$1 = expr_seq_to_int($1);
2018 		$3 = expr_seq_to_int($3);
2019 		switch ($1->type) {
2020 		case ITM_EXPR_INT:
2021 			switch ($3->type) {
2022 			case ITM_EXPR_INT:
2023 				$$ = expr_binary2(ITM_EXPR_LT_D_D, $1, $3);
2024 				break;
2025 			case ITM_EXPR_REG:
2026 				$$ = expr_binary2(ITM_EXPR_LT_D_R, $1, $3);
2027 				break;
2028 			case ITM_EXPR_IN_VECTOR_D:
2029 				$$ = expr_binary2(ITM_EXPR_LT_D_INVD, $1, $3);
2030 				break;
2031 			default:
2032 				$$ = expr_binary2(ITM_EXPR_LT_D_E, $1, $3);
2033 				break;
2034 			}
2035 			break;
2036 		case ITM_EXPR_REG:
2037 			switch ($3->type) {
2038 			case ITM_EXPR_INT:
2039 				$$ = expr_binary2(ITM_EXPR_LT_R_D, $1, $3);
2040 				break;
2041 			case ITM_EXPR_REG:
2042 				$$ = expr_binary2(ITM_EXPR_LT_R_R, $1, $3);
2043 				break;
2044 			case ITM_EXPR_IN_VECTOR_D:
2045 				$$ = expr_binary2(ITM_EXPR_LT_R_INVD, $1, $3);
2046 				break;
2047 			default:
2048 				$$ = expr_binary2(ITM_EXPR_LT_R_E, $1, $3);
2049 				break;
2050 			}
2051 			break;
2052 		case ITM_EXPR_IN_VECTOR_D:
2053 			switch ($3->type) {
2054 			case ITM_EXPR_INT:
2055 				$$ = expr_binary2(ITM_EXPR_LT_INVD_D, $1, $3);
2056 				break;
2057 			case ITM_EXPR_REG:
2058 				$$ = expr_binary2(ITM_EXPR_LT_INVD_R, $1, $3);
2059 				break;
2060 			case ITM_EXPR_IN_VECTOR_D:
2061 				$$ = expr_binary2(ITM_EXPR_LT_INVD_INVD,
2062 					$1, $3);
2063 				break;
2064 			default:
2065 				$$ = expr_binary2(ITM_EXPR_LT_INVD_E, $1, $3);
2066 				break;
2067 			}
2068 			break;
2069 		default:
2070 			switch ($3->type) {
2071 			case ITM_EXPR_INT:
2072 				$$ = expr_binary2(ITM_EXPR_LT_E_D, $1, $3);
2073 				break;
2074 			case ITM_EXPR_REG:
2075 				$$ = expr_binary2(ITM_EXPR_LT_E_R, $1, $3);
2076 				break;
2077 			case ITM_EXPR_IN_VECTOR_D:
2078 				$$ = expr_binary2(ITM_EXPR_LT_E_INVD, $1, $3);
2079 				break;
2080 			default:
2081 				$$ = expr_binary2(ITM_EXPR_LT, $1, $3);
2082 				break;
2083 				}
2084 			break;
2085 		}
2086 	}
2087 	| expr LE  expr
2088 	{
2089 		TRACE_MESSAGE('y', ("expr: expr <= expr\n"));
2090 		$$ = expr_binary(ITM_EXPR_LE, $1, $3);
2091 		$1 = expr_seq_to_int($1);
2092 		$3 = expr_seq_to_int($3);
2093 		switch ($1->type) {
2094 		case ITM_EXPR_INT:
2095 			switch ($3->type) {
2096 			case ITM_EXPR_INT:
2097 				$$ = expr_binary2(ITM_EXPR_LE_D_D, $1, $3);
2098 				break;
2099 			case ITM_EXPR_REG:
2100 				$$ = expr_binary2(ITM_EXPR_LE_D_R, $1, $3);
2101 				break;
2102 			case ITM_EXPR_IN_VECTOR_D:
2103 				$$ = expr_binary2(ITM_EXPR_LE_D_INVD, $1, $3);
2104 				break;
2105 			default:
2106 				$$ = expr_binary2(ITM_EXPR_LE_D_E, $1, $3);
2107 				break;
2108 			}
2109 			break;
2110 		case ITM_EXPR_REG:
2111 			switch ($3->type) {
2112 			case ITM_EXPR_INT:
2113 				$$ = expr_binary2(ITM_EXPR_LE_R_D, $1, $3);
2114 				break;
2115 			case ITM_EXPR_REG:
2116 				$$ = expr_binary2(ITM_EXPR_LE_R_R, $1, $3);
2117 				break;
2118 			case ITM_EXPR_IN_VECTOR_D:
2119 				$$ = expr_binary2(ITM_EXPR_LE_R_INVD, $1, $3);
2120 				break;
2121 			default:
2122 				$$ = expr_binary2(ITM_EXPR_LE_R_E, $1, $3);
2123 				break;
2124 			}
2125 			break;
2126 		case ITM_EXPR_IN_VECTOR_D:
2127 			switch ($3->type) {
2128 			case ITM_EXPR_INT:
2129 				$$ = expr_binary2(ITM_EXPR_LE_INVD_D, $1, $3);
2130 				break;
2131 			case ITM_EXPR_REG:
2132 				$$ = expr_binary2(ITM_EXPR_LE_INVD_R, $1, $3);
2133 				break;
2134 			case ITM_EXPR_IN_VECTOR_D:
2135 				$$ = expr_binary2(ITM_EXPR_LE_INVD_INVD,
2136 					$1, $3);
2137 				break;
2138 			default:
2139 				$$ = expr_binary2(ITM_EXPR_LE_INVD_E, $1, $3);
2140 				break;
2141 			}
2142 			break;
2143 		default:
2144 			switch ($3->type) {
2145 			case ITM_EXPR_INT:
2146 				$$ = expr_binary2(ITM_EXPR_LE_E_D, $1, $3);
2147 				break;
2148 			case ITM_EXPR_REG:
2149 				$$ = expr_binary2(ITM_EXPR_LE_E_R, $1, $3);
2150 				break;
2151 			case ITM_EXPR_IN_VECTOR_D:
2152 				$$ = expr_binary2(ITM_EXPR_LE_E_INVD, $1, $3);
2153 				break;
2154 			default:
2155 				$$ = expr_binary2(ITM_EXPR_LE, $1, $3);
2156 				break;
2157 			}
2158 			break;
2159 		}
2160 	}
2161 	| name ASSIGN expr
2162 	{
2163 		TRACE_MESSAGE('y', ("expr: NAME = expr\n"));
2164 		$$ = expr_assign(ITM_EXPR_ASSIGN, $1, $3);
2165 	}
2166 	| expr LOR expr
2167 	{
2168 		TRACE_MESSAGE('y', ("expr: expr || expr\n"));
2169 		$$ = expr_binary(ITM_EXPR_LOR, $1, $3);
2170 	}
2171 	| expr LAND expr
2172 	{
2173 		TRACE_MESSAGE('y', ("expr: expr && expr\n"));
2174 		$$ = expr_binary(ITM_EXPR_LAND, $1, $3);
2175 	}
2176 	;
2177 
2178 %%
2179