| @@ -1,15 +1,15 @@ | | | @@ -1,15 +1,15 @@ |
1 | %{ | | 1 | %{ |
2 | /* $NetBSD: arith.y,v 1.23 2016/03/16 15:42:33 christos Exp $ */ | | 2 | /* $NetBSD: arith.y,v 1.24 2016/03/16 15:43:38 christos Exp $ */ |
3 | | | 3 | |
4 | /*- | | 4 | /*- |
5 | * Copyright (c) 1993 | | 5 | * Copyright (c) 1993 |
6 | * The Regents of the University of California. All rights reserved. | | 6 | * The Regents of the University of California. All rights reserved. |
7 | * | | 7 | * |
8 | * This code is derived from software contributed to Berkeley by | | 8 | * This code is derived from software contributed to Berkeley by |
9 | * Kenneth Almquist. | | 9 | * Kenneth Almquist. |
10 | * | | 10 | * |
11 | * Redistribution and use in source and binary forms, with or without | | 11 | * Redistribution and use in source and binary forms, with or without |
12 | * modification, are permitted provided that the following conditions | | 12 | * modification, are permitted provided that the following conditions |
13 | * are met: | | 13 | * are met: |
14 | * 1. Redistributions of source code must retain the above copyright | | 14 | * 1. Redistributions of source code must retain the above copyright |
15 | * notice, this list of conditions and the following disclaimer. | | 15 | * notice, this list of conditions and the following disclaimer. |
| @@ -28,27 +28,27 @@ | | | @@ -28,27 +28,27 @@ |
28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
33 | * SUCH DAMAGE. | | 33 | * SUCH DAMAGE. |
34 | */ | | 34 | */ |
35 | | | 35 | |
36 | #include <sys/cdefs.h> | | 36 | #include <sys/cdefs.h> |
37 | #ifndef lint | | 37 | #ifndef lint |
38 | #if 0 | | 38 | #if 0 |
39 | static char sccsid[] = "@(#)arith.y 8.3 (Berkeley) 5/4/95"; | | 39 | static char sccsid[] = "@(#)arith.y 8.3 (Berkeley) 5/4/95"; |
40 | #else | | 40 | #else |
41 | __RCSID("$NetBSD: arith.y,v 1.23 2016/03/16 15:42:33 christos Exp $"); | | 41 | __RCSID("$NetBSD: arith.y,v 1.24 2016/03/16 15:43:38 christos Exp $"); |
42 | #endif | | 42 | #endif |
43 | #endif /* not lint */ | | 43 | #endif /* not lint */ |
44 | | | 44 | |
45 | #include <stdlib.h> | | 45 | #include <stdlib.h> |
46 | #include "expand.h" | | 46 | #include "expand.h" |
47 | #include "builtins.h" | | 47 | #include "builtins.h" |
48 | #include "shell.h" | | 48 | #include "shell.h" |
49 | #include "error.h" | | 49 | #include "error.h" |
50 | #include "output.h" | | 50 | #include "output.h" |
51 | #include "memalloc.h" | | 51 | #include "memalloc.h" |
52 | | | 52 | |
53 | typedef intmax_t YYSTYPE; | | 53 | typedef intmax_t YYSTYPE; |
54 | #define YYSTYPE YYSTYPE | | 54 | #define YYSTYPE YYSTYPE |
| @@ -81,28 +81,28 @@ int error(char *); | | | @@ -81,28 +81,28 @@ int error(char *); |
81 | | | 81 | |
82 | exp: expr { | | 82 | exp: expr { |
83 | /* | | 83 | /* |
84 | * yyparse() returns int, so we have to save | | 84 | * yyparse() returns int, so we have to save |
85 | * the desired result elsewhere. | | 85 | * the desired result elsewhere. |
86 | */ | | 86 | */ |
87 | arith_result = $1; | | 87 | arith_result = $1; |
88 | } | | 88 | } |
89 | ; | | 89 | ; |
90 | | | 90 | |
91 | | | 91 | |
92 | expr: ARITH_LPAREN expr ARITH_RPAREN { $$ = $2; } | | 92 | expr: ARITH_LPAREN expr ARITH_RPAREN { $$ = $2; } |
93 | | expr ARITH_QM expr ARITH_COLON expr { $$ = $1 ? $3 : $5; } | | 93 | | expr ARITH_QM expr ARITH_COLON expr { $$ = $1 ? $3 : $5; } |
94 | | expr ARITH_OR expr { $$ = $1 ? $1 : $3 ? $3 : 0; } | | 94 | | expr ARITH_OR expr { $$ = ($1 ? 1 : $3 ? 1 : 0); } |
95 | | expr ARITH_AND expr { $$ = $1 ? ( $3 ? $3 : 0 ) : 0; } | | 95 | | expr ARITH_AND expr { $$ = ($1 ? ( $3 ? 1 : 0 ) : 0); } |
96 | | expr ARITH_BOR expr { $$ = $1 | $3; } | | 96 | | expr ARITH_BOR expr { $$ = $1 | $3; } |
97 | | expr ARITH_BXOR expr { $$ = $1 ^ $3; } | | 97 | | expr ARITH_BXOR expr { $$ = $1 ^ $3; } |
98 | | expr ARITH_BAND expr { $$ = $1 & $3; } | | 98 | | expr ARITH_BAND expr { $$ = $1 & $3; } |
99 | | expr ARITH_EQ expr { $$ = $1 == $3; } | | 99 | | expr ARITH_EQ expr { $$ = $1 == $3; } |
100 | | expr ARITH_GT expr { $$ = $1 > $3; } | | 100 | | expr ARITH_GT expr { $$ = $1 > $3; } |
101 | | expr ARITH_GE expr { $$ = $1 >= $3; } | | 101 | | expr ARITH_GE expr { $$ = $1 >= $3; } |
102 | | expr ARITH_LT expr { $$ = $1 < $3; } | | 102 | | expr ARITH_LT expr { $$ = $1 < $3; } |
103 | | expr ARITH_LE expr { $$ = $1 <= $3; } | | 103 | | expr ARITH_LE expr { $$ = $1 <= $3; } |
104 | | expr ARITH_NE expr { $$ = $1 != $3; } | | 104 | | expr ARITH_NE expr { $$ = $1 != $3; } |
105 | | expr ARITH_LSHIFT expr { $$ = $1 << $3; } | | 105 | | expr ARITH_LSHIFT expr { $$ = $1 << $3; } |
106 | | expr ARITH_RSHIFT expr { $$ = $1 >> $3; } | | 106 | | expr ARITH_RSHIFT expr { $$ = $1 >> $3; } |
107 | | expr ARITH_ADD expr { $$ = $1 + $3; } | | 107 | | expr ARITH_ADD expr { $$ = $1 + $3; } |
108 | | expr ARITH_SUB expr { $$ = $1 - $3; } | | 108 | | expr ARITH_SUB expr { $$ = $1 - $3; } |