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