1 /* Implementation specifics for expression evaluation.
3 Copyright 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
5 This file is part of the GNU MP Library.
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 3 of the License, or (at your
10 option) any later version.
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.
17 You should have received a copy of the GNU Lesser General Public License
18 along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
21 /* Same tests as gmp.h. */
22 #if defined (__STDC__) \
23 || defined (__cplusplus) \
26 || (defined (__mips) && defined (_SYSTYPE_SVR4)) \
27 || defined (_MSC_VER) \
39 #define isasciidigit(c) (isascii (c) && isdigit (c))
40 #define isasciicsym(c) (isascii (c) && (isalnum(c) || (c) == '_'))
42 #define isasciidigit_in_base(c,base) \
44 && ((isdigit (c) && (c)-'0' < (base)) \
45 || (isupper (c) && (c)-'A'+10 < (base)) \
46 || (islower (c) && (c)-'a'+10 < (base))))
55 typedef union mpX_t *mpX_ptr;
56 typedef __gmp_const union mpX_t *mpX_srcptr;
58 typedef void (*mpexpr_fun_one_t) __GMP_PROTO ((mpX_ptr));
59 typedef unsigned long (*mpexpr_fun_ui_one_t) __GMP_PROTO ((mpX_ptr));
61 typedef void (*mpexpr_fun_0ary_t) __GMP_PROTO ((mpX_ptr));
62 typedef int (*mpexpr_fun_i_0ary_t) __GMP_PROTO ((void));
64 typedef void (*mpexpr_fun_unary_t) __GMP_PROTO ((mpX_ptr, mpX_srcptr));
65 typedef void (*mpexpr_fun_unary_ui_t) __GMP_PROTO ((mpX_ptr, unsigned long));
66 typedef int (*mpexpr_fun_i_unary_t) __GMP_PROTO ((mpX_srcptr));
67 typedef int (*mpexpr_fun_i_unary_ui_t) __GMP_PROTO ((unsigned long));
69 typedef void (*mpexpr_fun_binary_t) __GMP_PROTO ((mpX_ptr, mpX_srcptr, mpX_srcptr));
70 typedef void (*mpexpr_fun_binary_ui_t) __GMP_PROTO ((mpX_ptr, mpX_srcptr, unsigned long));
71 typedef int (*mpexpr_fun_i_binary_t) __GMP_PROTO ((mpX_srcptr, mpX_srcptr));
72 typedef int (*mpexpr_fun_i_binary_ui_t) __GMP_PROTO ((mpX_srcptr, unsigned long));
74 typedef void (*mpexpr_fun_ternary_t)
75 __GMP_PROTO ((mpX_ptr, mpX_srcptr, mpX_srcptr, mpX_srcptr));
76 typedef void (*mpexpr_fun_ternary_ui_t)
77 __GMP_PROTO ((mpX_ptr, mpX_srcptr, mpX_srcptr, unsigned long));
78 typedef int (*mpexpr_fun_i_ternary_t)
79 __GMP_PROTO ((mpX_srcptr, mpX_srcptr, mpX_srcptr));
80 typedef int (*mpexpr_fun_i_ternary_ui_t)
81 __GMP_PROTO ((mpX_srcptr, mpX_srcptr, unsigned long));
83 typedef size_t (*mpexpr_fun_number_t)
84 __GMP_PROTO ((mpX_ptr, __gmp_const char *str, size_t len, int base));
85 typedef void (*mpexpr_fun_swap_t) __GMP_PROTO ((mpX_ptr, mpX_ptr));
86 typedef unsigned long (*mpexpr_fun_get_ui_t) __GMP_PROTO ((mpX_srcptr));
87 typedef void (*mpexpr_fun_set_si_t) __GMP_PROTO ((mpX_srcptr, long));
89 struct mpexpr_control_t {
90 __gmp_const struct mpexpr_operator_t *op;
94 #define MPEXPR_VARIABLES 26
96 struct mpexpr_parse_t {
97 __gmp_const struct mpexpr_operator_t *table;
108 __gmp_const struct mpexpr_operator_t *token_op;
110 union mpX_t *data_stack;
115 struct mpexpr_control_t *control_stack;
120 mpexpr_fun_0ary_t mpX_clear;
121 mpexpr_fun_i_unary_t mpX_ulong_p;
122 mpexpr_fun_get_ui_t mpX_get_ui;
123 mpexpr_fun_unary_ui_t mpX_init;
124 mpexpr_fun_number_t mpX_number;
125 mpexpr_fun_unary_t mpX_set;
126 mpexpr_fun_unary_t mpX_set_or_swap;
127 mpexpr_fun_set_si_t mpX_set_si;
128 mpexpr_fun_swap_t mpX_swap;
132 int mpexpr_evaluate __GMP_PROTO ((struct mpexpr_parse_t *p));
133 int mpexpr_va_to_var __GMP_PROTO ((void *var[], va_list ap));
134 size_t mpexpr_mpz_number __GMP_PROTO ((mpz_ptr res,
135 __gmp_const char *e, size_t elen, int base));