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
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.
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]
26 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
27 * Use is subject to license terms.
30 /* Copyright (c) 1988 AT&T */
31 /* All Rights Reserved */
34 #pragma ident "%Z%%M% %I% %E% SMI"
45 %nonassoc GT GE LT LE NE EQ
52 s
: e
= { evalval
= $1; }
56 e
: e OROR e
= { $$
= ($1 != 0 ||
$3 != 0) ?
1 : 0; }
57 | e ANDAND e
= { $$
= ($1 != 0 && $3 != 0) ?
1 : 0; }
58 |
'!' e
= { $$
= $2 == 0; }
59 |
'~' e
= { $$
= ~
$2; }
60 | e EQ e
= { $$
= $1 == $3; }
61 | e NE e
= { $$
= $1 != $3; }
62 | e GT e
= { $$
= $1 > $3; }
63 | e GE e
= { $$
= $1 >= $3; }
64 | e LT e
= { $$
= $1 < $3; }
65 | e LE e
= { $$
= $1 <= $3; }
66 | e
'|' e
= { $$
= ($1 |
$3); }
67 | e
'&' e
= { $$
= ($1 & $3); }
68 | e
'^' e
= { $$
= ($1 ^
$3); }
69 | e
'+' e
= { $$
= ($1 + $3); }
70 | e
'-' e
= { $$
= ($1 - $3); }
71 | e
'*' e
= { $$
= ($1 * $3); }
72 | e
'/' e
= { $$
= ($1 / $3); }
73 | e
'%' e
= { $$
= ($1 %
$3); }
74 |
'(' e
')' = { $$
= ($2); }
75 | e POWER e
= { for
($$
= 1; $3-- > 0; $$
*= $1); }
76 |
'-' e %prec UMINUS
= { $$
= $2-1; $$
= -$2; }
77 |
'+' e %prec UMINUS
= { $$
= $2-1; $$
= $2; }
78 | DIGITS
= { $$
= evalval
; }
85 static int peek
(int c
, int r1
, int r2
);
90 while
(*pe
== ' ' ||
*pe
== '\t' ||
*pe
== '\n')
104 return
(peek
('*', POWER
, '*'));
106 return
(peek
('=', GE
, GT
));
108 return
(peek
('=', LE
, LT
));
110 return
(peek
('=', EQ
, EQ
));
112 return
(peek
('|', OROR
, '|'));
114 return
(peek
('&', ANDAND
, '&'));
116 return
(peek
('=', NE
, '!'));
123 if
(*++pe
== 'x' ||
*pe
== 'X') {
138 else if
(c
>= 'a' && c
<= 'f')
140 else if
(c
>= 'A' && c
<= 'F')
145 evalval
= evalval
*base
+ dig
;
154 peek
(int c
, int r1
, int r2
)
164 yyerror(YYCONST
char *msg
)