das2C
das core C utilities (v3)
Loading...
Searching...
No Matches
operator.h
1/* Copyright (C) 2018 Chris Piker <chris-piker@uiowa.edu>
2 *
3 * This file is part of das2C, the Core Das2 C Library.
4 *
5 * Das2C is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU Lesser General Public License version 2.1 as published
7 * by the Free Software Foundation.
8 *
9 * Das2C is distributed in the hope that it will be useful, but WITHOUT ANY
10 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * version 2.1 along with das2C; if not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef _das_operator_h_
19#define _das_operator_h_
20
21#include <das3/defs.h>
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27/* Invalid Operator */
28#define D2OP_INVALID 0
29
30/* Unary operators, before */
31#define D2UOP_SIGN 1
32#define D2UOP_SQRT 7
33#define D2UOP_CURT 8
34#define D2UOP_LOG10 9
35#define D2UOP_LN 10
36#define D2UOP_COS 11
37#define D2UOP_SIN 12
38#define D2UOP_TAN 13
39
40/* Unary operators after */
41#define D2UOP_SQUARE 101
42#define D2UOP_CUBE 102
43#define D2UOP_INV 103
44#define D2UOP_INVSQ 104
45#define D2UOP_INVCUBE 105
46
47/* Binary operators */
48#define D2BOP_ADD 201
49#define D2BOP_SUB 202
50#define D2BOP_MUL 203
51#define D2BOP_DIV 204
52#define D2BOP_POW 205
53
54/* Operator positions */
55#define D2OP_BEFORE 1
56#define D2OP_BETWEEN 2
57#define D2OP_AFTER 3
58
59
71DAS_API int das_op_unary(const char* sOp);
72
80DAS_API int das_op_binary(const char* sOp);
81
94DAS_API const char* das_op_toStr(int nOp, int* pos);
95
97DAS_API bool das_op_isBinary(int nOp);
98
100DAS_API bool das_op_isUnary(int nOp);
101
104#ifdef __cplusplus
105}
106#endif
107
108#endif /* _das_operator_h_ */
109
Minimal definitions for das2 utilities that can safely be run without calling das_init().
DAS_API bool das_op_isUnary(int nOp)
Return true if op is a unary operation, false otherwise.
DAS_API bool das_op_isBinary(int nOp)
Return true if this is a binary operation, false otherwise.
DAS_API const char * das_op_toStr(int nOp, int *pos)
Provide a string representation of an operator token and an indication of where the operator normally...
DAS_API int das_op_binary(const char *sOp)
Convert a string into a binary operator token.
DAS_API int das_op_unary(const char *sOp)
Convert a string into a unary operator token.