Annotation of OpenXM_contrib/gmp/demos/expr/expr.h, Revision 1.1
1.1 ! ohara 1: /* Header for expression evaluation.
! 2:
! 3: Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
! 4:
! 5: This file is part of the GNU MP Library.
! 6:
! 7: The GNU MP Library is free software; you can redistribute it and/or modify
! 8: it under the terms of the GNU Lesser General Public License as published by
! 9: the Free Software Foundation; either version 2.1 of the License, or (at your
! 10: option) any later version.
! 11:
! 12: The GNU MP Library is distributed in the hope that it will be useful, but
! 13: WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
! 14: or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
! 15: License for more details.
! 16:
! 17: You should have received a copy of the GNU Lesser General Public License
! 18: along with the GNU MP Library; see the file COPYING.LIB. If not, write to
! 19: the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
! 20: MA 02111-1307, USA.
! 21: */
! 22:
! 23:
! 24: #ifndef __EXPR_H__
! 25: #define __EXPR_H__
! 26:
! 27: #define MPEXPR_RESULT_OK 0
! 28: #define MPEXPR_RESULT_BAD_VARIABLE 1
! 29: #define MPEXPR_RESULT_BAD_TABLE 2
! 30: #define MPEXPR_RESULT_PARSE_ERROR 3
! 31: #define MPEXPR_RESULT_NOT_UI 4
! 32:
! 33:
! 34: /* basic types */
! 35: #define MPEXPR_TYPE_NARY(n) ((n) * 0x0100)
! 36: #define MPEXPR_TYPE_MASK_ARGCOUNT MPEXPR_TYPE_NARY(0xF)
! 37: #define MPEXPR_TYPE_0ARY MPEXPR_TYPE_NARY(0)
! 38: #define MPEXPR_TYPE_UNARY MPEXPR_TYPE_NARY(1)
! 39: #define MPEXPR_TYPE_BINARY MPEXPR_TYPE_NARY(2)
! 40: #define MPEXPR_TYPE_TERNARY MPEXPR_TYPE_NARY(3)
! 41:
! 42: /* options for all */
! 43: #define MPEXPR_TYPE_LAST_UI 0x0010
! 44: #define MPEXPR_TYPE_RESULT_INT 0x0020
! 45: #define MPEXPR_TYPE_MASK_ARGSTYLE 0x0030
! 46:
! 47: #define MPEXPR_TYPE_UNARY_UI (MPEXPR_TYPE_UNARY | MPEXPR_TYPE_LAST_UI)
! 48: #define MPEXPR_TYPE_I_UNARY (MPEXPR_TYPE_UNARY | MPEXPR_TYPE_RESULT_INT)
! 49: #define MPEXPR_TYPE_I_UNARY_UI (MPEXPR_TYPE_I_UNARY | MPEXPR_TYPE_LAST_UI)
! 50: #define MPEXPR_TYPE_BINARY_UI (MPEXPR_TYPE_BINARY | MPEXPR_TYPE_LAST_UI)
! 51: #define MPEXPR_TYPE_I_BINARY (MPEXPR_TYPE_BINARY | MPEXPR_TYPE_RESULT_INT)
! 52: #define MPEXPR_TYPE_I_BINARY_UI (MPEXPR_TYPE_I_BINARY| MPEXPR_TYPE_LAST_UI)
! 53: #define MPEXPR_TYPE_TERNARY_UI (MPEXPR_TYPE_TERNARY | MPEXPR_TYPE_LAST_UI)
! 54: #define MPEXPR_TYPE_I_TERNARY (MPEXPR_TYPE_TERNARY | MPEXPR_TYPE_RESULT_INT)
! 55: #define MPEXPR_TYPE_I_TERNARY_UI (MPEXPR_TYPE_I_TERNARY|MPEXPR_TYPE_LAST_UI)
! 56:
! 57: /* 0ary with options */
! 58: #define MPEXPR_TYPE_CONSTANT (MPEXPR_TYPE_0ARY | 0x0040)
! 59:
! 60: /* unary options */
! 61: #define MPEXPR_TYPE_PREFIX 0x0040
! 62:
! 63: /* binary options */
! 64: #define MPEXPR_TYPE_RIGHTASSOC 0x0040
! 65: #define MPEXPR_TYPE_PAIRWISE 0x0080
! 66:
! 67: #define MPEXPR_TYPE_MASK_SPECIAL 0x000F
! 68:
! 69: /* unary specials */
! 70: #define MPEXPR_TYPE_NEW_TABLE (MPEXPR_TYPE_UNARY | 0x001)
! 71: #define MPEXPR_TYPE_DONE (MPEXPR_TYPE_UNARY | 0x002)
! 72: #define MPEXPR_TYPE_VARIABLE (MPEXPR_TYPE_UNARY | 0x003)
! 73: #define MPEXPR_TYPE_LOGICAL_NOT (MPEXPR_TYPE_UNARY | 0x004)
! 74: #define MPEXPR_TYPE_CLOSEPAREN (MPEXPR_TYPE_UNARY | 0x005)
! 75: #define MPEXPR_TYPE_OPENPAREN (MPEXPR_TYPE_CLOSEPAREN | MPEXPR_TYPE_PREFIX)
! 76:
! 77: /* binary specials */
! 78: #define MPEXPR_TYPE_LOGICAL_AND (MPEXPR_TYPE_BINARY | 0x001)
! 79: #define MPEXPR_TYPE_LOGICAL_OR (MPEXPR_TYPE_BINARY | 0x002)
! 80: #define MPEXPR_TYPE_ARGSEP (MPEXPR_TYPE_BINARY | 0x003)
! 81: #define MPEXPR_TYPE_QUESTION (MPEXPR_TYPE_BINARY | 0x004)
! 82: #define MPEXPR_TYPE_COLON (MPEXPR_TYPE_BINARY | 0x005)
! 83: #define MPEXPR_TYPE_MAX (MPEXPR_TYPE_BINARY | 0x006)
! 84: #define MPEXPR_TYPE_MIN (MPEXPR_TYPE_BINARY | 0x007)
! 85: #define MPEXPR_TYPE_MASK_CMP 0x008
! 86: #define MPEXPR_TYPE_MASK_CMP_LT 0x001
! 87: #define MPEXPR_TYPE_MASK_CMP_EQ 0x002
! 88: #define MPEXPR_TYPE_MASK_CMP_GT 0x004
! 89: #define MPEXPR_TYPE_CMP_LT (MPEXPR_TYPE_BINARY | MPEXPR_TYPE_MASK_CMP \
! 90: | MPEXPR_TYPE_MASK_CMP_LT)
! 91: #define MPEXPR_TYPE_CMP_EQ (MPEXPR_TYPE_BINARY | MPEXPR_TYPE_MASK_CMP \
! 92: | MPEXPR_TYPE_MASK_CMP_EQ)
! 93: #define MPEXPR_TYPE_CMP_GT (MPEXPR_TYPE_BINARY | MPEXPR_TYPE_MASK_CMP \
! 94: | MPEXPR_TYPE_MASK_CMP_GT)
! 95: #define MPEXPR_TYPE_CMP_LE (MPEXPR_TYPE_CMP_LT | MPEXPR_TYPE_MASK_CMP_EQ)
! 96: #define MPEXPR_TYPE_CMP_NE (MPEXPR_TYPE_CMP_LT | MPEXPR_TYPE_MASK_CMP_GT)
! 97: #define MPEXPR_TYPE_CMP_GE (MPEXPR_TYPE_CMP_GT | MPEXPR_TYPE_MASK_CMP_EQ)
! 98:
! 99: /* parse options */
! 100: #define MPEXPR_TYPE_WHOLEWORD 0x1000
! 101: #define MPEXPR_TYPE_OPERATOR 0x2000
! 102:
! 103:
! 104: typedef void (*mpexpr_fun_t) __GMP_PROTO ((void));
! 105:
! 106: struct mpexpr_operator_t {
! 107: __gmp_const char *name;
! 108: mpexpr_fun_t fun;
! 109: int type;
! 110: int precedence;
! 111: };
! 112:
! 113:
! 114: int mpf_expr_a __GMP_PROTO ((__gmp_const struct mpexpr_operator_t *table,
! 115: mpf_ptr res, int base, unsigned long prec,
! 116: __gmp_const char *e, size_t elen,
! 117: mpf_srcptr var[26]));
! 118: int mpf_expr __GMP_PROTO ((mpf_ptr res, int base, __gmp_const char *e, ...));
! 119:
! 120: int mpq_expr_a __GMP_PROTO ((__gmp_const struct mpexpr_operator_t *table,
! 121: mpq_ptr res, int base,
! 122: __gmp_const char *e, size_t elen,
! 123: mpq_srcptr var[26]));
! 124: int mpq_expr __GMP_PROTO ((mpq_ptr res, int base, __gmp_const char *e, ...));
! 125:
! 126: int mpz_expr_a __GMP_PROTO ((__gmp_const struct mpexpr_operator_t *table,
! 127: mpz_ptr res, int base,
! 128: __gmp_const char *e, size_t elen,
! 129: mpz_srcptr var[26]));
! 130: int mpz_expr __GMP_PROTO ((mpz_ptr res, int base, __gmp_const char *e, ...));
! 131:
! 132: /* when mpfr.h has been included */
! 133: #ifdef GMP_RNDZ
! 134: int mpfr_expr_a __GMP_PROTO ((__gmp_const struct mpexpr_operator_t *table,
! 135: mpfr_ptr res, int base, unsigned long prec,
! 136: __gmp_const char *e, size_t elen,
! 137: mpfr_srcptr var[26]));
! 138: int mpfr_expr __GMP_PROTO ((mpfr_ptr res, int base, __gmp_const char *e, ...));
! 139: #endif
! 140:
! 141: #endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>