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"
54 s
: e
= { evalval
= $1; }
58 e
: e OROR e
= { $$
= ($1 != 0 ||
$3 != 0) ?
1 : 0; }
59 | e ANDAND e
= { $$
= ($1 != 0 && $3 != 0) ?
1 : 0; }
60 |
'!' e
= { $$
= $2 == 0; }
61 |
'~' e
= { $$
= ~
$2; }
62 | e EQ e
= { $$
= $1 == $3; }
63 | e NE e
= { $$
= $1 != $3; }
64 | e GT e
= { $$
= $1 > $3; }
65 | e GE e
= { $$
= $1 >= $3; }
66 | e LT e
= { $$
= $1 < $3; }
67 | e LE e
= { $$
= $1 <= $3; }
68 | e LSHIFT e
= { $$
= $1 << $3; }
69 | e RSHIFT 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
'-' e
= { $$
= ($1 - $3); }
75 | e
'*' e
= { $$
= ($1 * $3); }
76 | e
'/' e
= { $$
= ($1 / $3); }
77 | e
'%' e
= { $$
= ($1 %
$3); }
78 |
'(' e
')' = { $$
= ($2); }
79 | e POWER e
= { for
($$
= 1; $3-- > 0; $$
*= $1); }
80 |
'-' e %prec UMINUS
= { $$
= $2-1; $$
= -$2; }
81 |
'+' e %prec UMINUS
= { $$
= $2-1; $$
= $2; }
82 | DIGITS
= { $$
= evalval
; }
90 static int peek
(char c
, int r1
, int r2
);
91 static int peek3
(char c1
, int rc1
, char c2
, int rc2
, int rc3
);
96 while
(*pe
== ' ' ||
*pe
== '\t' ||
*pe
== '\n')
110 return
(peek
('*', POWER
, '*'));
112 return
(peek3
('=', GE
, '>', RSHIFT
, GT
));
114 return
(peek3
('=', LE
, '<', LSHIFT
, LT
));
116 return
(peek
('=', EQ
, EQ
));
118 return
(peek
('|', OROR
, '|'));
120 return
(peek
('&', ANDAND
, '&'));
122 return
(peek
('=', NE
, '!'));
129 if
(*++pe
== 'x' ||
*pe
== 'X') {
144 else if
(c
>= 'a' && c
<= 'f')
146 else if
(c
>= 'A' && c
<= 'F')
151 evalval
= evalval
*base
+ dig
;
160 peek
(char c
, int r1
, int r2
)
169 peek3
(char c1
, int rc1
, char c2
, int rc2
, int rc3
)
185 yyerror(YYCONST
char *msg
)