arith_yacc.h (3086B)
1 /* - 2 * spdx-license-identifier: bsd-3-clause 3 * 4 * copyright (c) 1993 5 * the regents of the university of california. all rights reserved 6 * copyright (c) 2007 7 * herbert xu <herbert@gondor.apana.org.au>. all rights reserved 8 * 9 * this code is derived from software contributed to berkeley by 10 * kenneth almquist 11 * 12 * redistribution and use in source and binary forms, with or without 13 * modification, are permitted provided that the following conditions 14 * are met: 15 * 1. redistributions of source code must retain the above copyright 16 * notice, this list of conditions and the following disclaimer 17 * 2. redistributions in binary form must reproduce the above copyright 18 * notice, this list of conditions and the following disclaimer in the 19 * documentation and/or other materials provided with the distribution 20 * 3. neither the name of the university nor the names of its contributors 21 * may be used to endorse or promote products derived from this software 22 * without specific prior written permission 23 * 24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR a PARTICULAR PURPOSE 27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE 35 */ 36 37 #include "shell.h" 38 39 #define ARITH_ASS 1 40 41 #define ARITH_OR 2 42 #define ARITH_AND 3 43 #define ARITH_BAD 4 44 #define ARITH_NUM 5 45 #define ARITH_VAR 6 46 #define ARITH_NOT 7 47 48 #define ARITH_BINOP_MIN 8 49 #define ARITH_LE 8 50 #define ARITH_GE 9 51 #define ARITH_LT 10 52 #define ARITH_GT 11 53 #define ARITH_EQ 12 54 #define ARITH_REM 13 55 #define ARITH_BAND 14 56 #define ARITH_LSHIFT 15 57 #define ARITH_RSHIFT 16 58 #define ARITH_MUL 17 59 #define ARITH_ADD 18 60 #define ARITH_BOR 19 61 #define ARITH_SUB 20 62 #define ARITH_BXOR 21 63 #define ARITH_DIV 22 64 #define ARITH_NE 23 65 #define ARITH_BINOP_MAX 24 66 67 #define ARITH_ASS_MIN 24 68 #define ARITH_REMASS 24 69 #define ARITH_BANDASS 25 70 #define ARITH_LSHIFTASS 26 71 #define ARITH_RSHIFTASS 27 72 #define ARITH_MULASS 28 73 #define ARITH_ADDASS 29 74 #define ARITH_BORASS 30 75 #define ARITH_SUBASS 31 76 #define ARITH_BXORASS 32 77 #define ARITH_DIVASS 33 78 #define ARITH_ASS_MAX 34 79 80 #define ARITH_LPAREN 34 81 #define ARITH_RPAREN 35 82 #define ARITH_BNOT 36 83 #define ARITH_QMARK 37 84 #define ARITH_COLON 38 85 86 extern const char *arith_buf; 87 88 union yystype { 89 arith_t val; 90 char *name; 91 }; 92 93 extern union yystype yylval; 94 95 arith_t strtoarith_t(const char *restrict nptr, char **restrict endptr); 96 int yylex(void);