Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

563745 views
1
/* Implementation specifics for expression evaluation.
2
3
Copyright 2000, 2001, 2002, 2004 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., 51 Franklin Street, Fifth Floor, Boston,
20
MA 02110-1301, USA. */
21
22
23
/* Same tests as gmp.h. */
24
#if defined (__STDC__) \
25
|| defined (__cplusplus) \
26
|| defined (_AIX) \
27
|| defined (__DECC) \
28
|| (defined (__mips) && defined (_SYSTYPE_SVR4)) \
29
|| defined (_MSC_VER) \
30
|| defined (_WIN32)
31
#define HAVE_STDARG 1
32
#include <stdarg.h>
33
#else
34
#define HAVE_STDARG 0
35
#include <varargs.h>
36
#endif
37
38
#include "expr.h"
39
40
41
#define isasciidigit(c) (isascii (c) && isdigit (c))
42
#define isasciicsym(c) (isascii (c) && (isalnum(c) || (c) == '_'))
43
44
#define isasciidigit_in_base(c,base) \
45
(isascii (c) \
46
&& ((isdigit (c) && (c)-'0' < (base)) \
47
|| (isupper (c) && (c)-'A'+10 < (base)) \
48
|| (islower (c) && (c)-'a'+10 < (base))))
49
50
51
union mpX_t {
52
mpz_t z;
53
mpq_t q;
54
mpf_t f;
55
};
56
57
typedef union mpX_t *mpX_ptr;
58
typedef __gmp_const union mpX_t *mpX_srcptr;
59
60
typedef void (*mpexpr_fun_one_t) __GMP_PROTO ((mpX_ptr));
61
typedef unsigned long (*mpexpr_fun_ui_one_t) __GMP_PROTO ((mpX_ptr));
62
63
typedef void (*mpexpr_fun_0ary_t) __GMP_PROTO ((mpX_ptr));
64
typedef int (*mpexpr_fun_i_0ary_t) __GMP_PROTO ((void));
65
66
typedef void (*mpexpr_fun_unary_t) __GMP_PROTO ((mpX_ptr, mpX_srcptr));
67
typedef void (*mpexpr_fun_unary_ui_t) __GMP_PROTO ((mpX_ptr, unsigned long));
68
typedef int (*mpexpr_fun_i_unary_t) __GMP_PROTO ((mpX_srcptr));
69
typedef int (*mpexpr_fun_i_unary_ui_t) __GMP_PROTO ((unsigned long));
70
71
typedef void (*mpexpr_fun_binary_t) __GMP_PROTO ((mpX_ptr, mpX_srcptr, mpX_srcptr));
72
typedef void (*mpexpr_fun_binary_ui_t) __GMP_PROTO ((mpX_ptr, mpX_srcptr, unsigned long));
73
typedef int (*mpexpr_fun_i_binary_t) __GMP_PROTO ((mpX_srcptr, mpX_srcptr));
74
typedef int (*mpexpr_fun_i_binary_ui_t) __GMP_PROTO ((mpX_srcptr, unsigned long));
75
76
typedef void (*mpexpr_fun_ternary_t)
77
__GMP_PROTO ((mpX_ptr, mpX_srcptr, mpX_srcptr, mpX_srcptr));
78
typedef void (*mpexpr_fun_ternary_ui_t)
79
__GMP_PROTO ((mpX_ptr, mpX_srcptr, mpX_srcptr, unsigned long));
80
typedef int (*mpexpr_fun_i_ternary_t)
81
__GMP_PROTO ((mpX_srcptr, mpX_srcptr, mpX_srcptr));
82
typedef int (*mpexpr_fun_i_ternary_ui_t)
83
__GMP_PROTO ((mpX_srcptr, mpX_srcptr, unsigned long));
84
85
typedef size_t (*mpexpr_fun_number_t)
86
__GMP_PROTO ((mpX_ptr, __gmp_const char *str, size_t len, int base));
87
typedef void (*mpexpr_fun_swap_t) __GMP_PROTO ((mpX_ptr, mpX_ptr));
88
typedef unsigned long (*mpexpr_fun_get_ui_t) __GMP_PROTO ((mpX_srcptr));
89
typedef void (*mpexpr_fun_set_si_t) __GMP_PROTO ((mpX_srcptr, long));
90
91
struct mpexpr_control_t {
92
__gmp_const struct mpexpr_operator_t *op;
93
int argcount;
94
};
95
96
#define MPEXPR_VARIABLES 26
97
98
struct mpexpr_parse_t {
99
__gmp_const struct mpexpr_operator_t *table;
100
101
mpX_ptr res;
102
int base;
103
unsigned long prec;
104
__gmp_const char *e;
105
size_t elen;
106
mpX_srcptr *var;
107
int error_code;
108
109
int token;
110
__gmp_const struct mpexpr_operator_t *token_op;
111
112
union mpX_t *data_stack;
113
int data_top;
114
int data_alloc;
115
int data_inited;
116
117
struct mpexpr_control_t *control_stack;
118
int control_top;
119
int control_alloc;
120
121
122
mpexpr_fun_0ary_t mpX_clear;
123
mpexpr_fun_i_unary_t mpX_ulong_p;
124
mpexpr_fun_get_ui_t mpX_get_ui;
125
mpexpr_fun_unary_ui_t mpX_init;
126
mpexpr_fun_number_t mpX_number;
127
mpexpr_fun_unary_t mpX_set;
128
mpexpr_fun_unary_t mpX_set_or_swap;
129
mpexpr_fun_set_si_t mpX_set_si;
130
mpexpr_fun_swap_t mpX_swap;
131
};
132
133
134
int mpexpr_evaluate __GMP_PROTO ((struct mpexpr_parse_t *p));
135
int mpexpr_va_to_var __GMP_PROTO ((void *var[], va_list ap));
136
size_t mpexpr_mpz_number __GMP_PROTO ((mpz_ptr res,
137
__gmp_const char *e, size_t elen, int base));
138
139