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

563728 views
1
/* Header 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
#ifndef __EXPR_H__
24
#define __EXPR_H__
25
26
#define MPEXPR_RESULT_OK 0
27
#define MPEXPR_RESULT_BAD_VARIABLE 1
28
#define MPEXPR_RESULT_BAD_TABLE 2
29
#define MPEXPR_RESULT_PARSE_ERROR 3
30
#define MPEXPR_RESULT_NOT_UI 4
31
32
33
/* basic types */
34
#define MPEXPR_TYPE_NARY(n) ((n) * 0x0100)
35
#define MPEXPR_TYPE_MASK_ARGCOUNT MPEXPR_TYPE_NARY(0xF)
36
#define MPEXPR_TYPE_0ARY MPEXPR_TYPE_NARY(0)
37
#define MPEXPR_TYPE_UNARY MPEXPR_TYPE_NARY(1)
38
#define MPEXPR_TYPE_BINARY MPEXPR_TYPE_NARY(2)
39
#define MPEXPR_TYPE_TERNARY MPEXPR_TYPE_NARY(3)
40
41
/* options for all */
42
#define MPEXPR_TYPE_LAST_UI 0x0010
43
#define MPEXPR_TYPE_RESULT_INT 0x0020
44
#define MPEXPR_TYPE_MASK_ARGSTYLE 0x0030
45
46
#define MPEXPR_TYPE_UNARY_UI (MPEXPR_TYPE_UNARY | MPEXPR_TYPE_LAST_UI)
47
#define MPEXPR_TYPE_I_UNARY (MPEXPR_TYPE_UNARY | MPEXPR_TYPE_RESULT_INT)
48
#define MPEXPR_TYPE_I_UNARY_UI (MPEXPR_TYPE_I_UNARY | MPEXPR_TYPE_LAST_UI)
49
#define MPEXPR_TYPE_BINARY_UI (MPEXPR_TYPE_BINARY | MPEXPR_TYPE_LAST_UI)
50
#define MPEXPR_TYPE_I_BINARY (MPEXPR_TYPE_BINARY | MPEXPR_TYPE_RESULT_INT)
51
#define MPEXPR_TYPE_I_BINARY_UI (MPEXPR_TYPE_I_BINARY| MPEXPR_TYPE_LAST_UI)
52
#define MPEXPR_TYPE_TERNARY_UI (MPEXPR_TYPE_TERNARY | MPEXPR_TYPE_LAST_UI)
53
#define MPEXPR_TYPE_I_TERNARY (MPEXPR_TYPE_TERNARY | MPEXPR_TYPE_RESULT_INT)
54
#define MPEXPR_TYPE_I_TERNARY_UI (MPEXPR_TYPE_I_TERNARY|MPEXPR_TYPE_LAST_UI)
55
56
/* 0ary with options */
57
#define MPEXPR_TYPE_CONSTANT (MPEXPR_TYPE_0ARY | 0x0040)
58
59
/* unary options */
60
#define MPEXPR_TYPE_PREFIX 0x0040
61
62
/* binary options */
63
#define MPEXPR_TYPE_RIGHTASSOC 0x0040
64
#define MPEXPR_TYPE_PAIRWISE 0x0080
65
66
#define MPEXPR_TYPE_MASK_SPECIAL 0x000F
67
68
/* unary specials */
69
#define MPEXPR_TYPE_NEW_TABLE (MPEXPR_TYPE_UNARY | 0x001)
70
#define MPEXPR_TYPE_DONE (MPEXPR_TYPE_UNARY | 0x002)
71
#define MPEXPR_TYPE_VARIABLE (MPEXPR_TYPE_UNARY | 0x003)
72
#define MPEXPR_TYPE_LOGICAL_NOT (MPEXPR_TYPE_UNARY | 0x004)
73
#define MPEXPR_TYPE_CLOSEPAREN (MPEXPR_TYPE_UNARY | 0x005)
74
#define MPEXPR_TYPE_OPENPAREN (MPEXPR_TYPE_CLOSEPAREN | MPEXPR_TYPE_PREFIX)
75
76
/* binary specials */
77
#define MPEXPR_TYPE_LOGICAL_AND (MPEXPR_TYPE_BINARY | 0x001)
78
#define MPEXPR_TYPE_LOGICAL_OR (MPEXPR_TYPE_BINARY | 0x002)
79
#define MPEXPR_TYPE_ARGSEP (MPEXPR_TYPE_BINARY | 0x003)
80
#define MPEXPR_TYPE_QUESTION (MPEXPR_TYPE_BINARY | 0x004)
81
#define MPEXPR_TYPE_COLON (MPEXPR_TYPE_BINARY | 0x005)
82
#define MPEXPR_TYPE_MAX (MPEXPR_TYPE_BINARY | 0x006)
83
#define MPEXPR_TYPE_MIN (MPEXPR_TYPE_BINARY | 0x007)
84
#define MPEXPR_TYPE_MASK_CMP 0x008
85
#define MPEXPR_TYPE_MASK_CMP_LT 0x001
86
#define MPEXPR_TYPE_MASK_CMP_EQ 0x002
87
#define MPEXPR_TYPE_MASK_CMP_GT 0x004
88
#define MPEXPR_TYPE_CMP_LT (MPEXPR_TYPE_BINARY | MPEXPR_TYPE_MASK_CMP \
89
| MPEXPR_TYPE_MASK_CMP_LT)
90
#define MPEXPR_TYPE_CMP_EQ (MPEXPR_TYPE_BINARY | MPEXPR_TYPE_MASK_CMP \
91
| MPEXPR_TYPE_MASK_CMP_EQ)
92
#define MPEXPR_TYPE_CMP_GT (MPEXPR_TYPE_BINARY | MPEXPR_TYPE_MASK_CMP \
93
| MPEXPR_TYPE_MASK_CMP_GT)
94
#define MPEXPR_TYPE_CMP_LE (MPEXPR_TYPE_CMP_LT | MPEXPR_TYPE_MASK_CMP_EQ)
95
#define MPEXPR_TYPE_CMP_NE (MPEXPR_TYPE_CMP_LT | MPEXPR_TYPE_MASK_CMP_GT)
96
#define MPEXPR_TYPE_CMP_GE (MPEXPR_TYPE_CMP_GT | MPEXPR_TYPE_MASK_CMP_EQ)
97
98
/* parse options */
99
#define MPEXPR_TYPE_WHOLEWORD 0x1000
100
#define MPEXPR_TYPE_OPERATOR 0x2000
101
102
103
typedef void (*mpexpr_fun_t) __GMP_PROTO ((void));
104
105
struct mpexpr_operator_t {
106
__gmp_const char *name;
107
mpexpr_fun_t fun;
108
int type;
109
int precedence;
110
};
111
112
113
int mpf_expr_a __GMP_PROTO ((__gmp_const struct mpexpr_operator_t *table,
114
mpf_ptr res, int base, unsigned long prec,
115
__gmp_const char *e, size_t elen,
116
mpf_srcptr var[26]));
117
int mpf_expr __GMP_PROTO ((mpf_ptr res, int base, __gmp_const char *e, ...));
118
119
int mpq_expr_a __GMP_PROTO ((__gmp_const struct mpexpr_operator_t *table,
120
mpq_ptr res, int base,
121
__gmp_const char *e, size_t elen,
122
mpq_srcptr var[26]));
123
int mpq_expr __GMP_PROTO ((mpq_ptr res, int base, __gmp_const char *e, ...));
124
125
int mpz_expr_a __GMP_PROTO ((__gmp_const struct mpexpr_operator_t *table,
126
mpz_ptr res, int base,
127
__gmp_const char *e, size_t elen,
128
mpz_srcptr var[26]));
129
int mpz_expr __GMP_PROTO ((mpz_ptr res, int base, __gmp_const char *e, ...));
130
131
#endif
132
133