1 | /* -*- c-basic-offset: 2 -*- */ |
2 | /* |
3 | Copyright(C) 2015-2016-2016 Brazil |
4 | |
5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Lesser General Public |
7 | License version 2.1 as published by the Free Software Foundation. |
8 | |
9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Lesser General Public License for more details. |
13 | |
14 | You should have received a copy of the GNU Lesser General Public |
15 | License along with this library; if not, write to the Free Software |
16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
17 | */ |
18 | |
19 | #pragma once |
20 | |
21 | #include "../grn.h" |
22 | |
23 | #ifdef __cplusplus |
24 | extern "C" { |
25 | #endif |
26 | |
27 | /*------------------------------------------------------------- |
28 | * Operator types. |
29 | */ |
30 | |
31 | typedef enum { |
32 | /* Invalid operator. */ |
33 | GRN_TS_OP_NOP, |
34 | |
35 | /* Unary operators. */ |
36 | GRN_TS_OP_LOGICAL_NOT, /* !X */ |
37 | GRN_TS_OP_BITWISE_NOT, /* ~X */ |
38 | GRN_TS_OP_POSITIVE, /* +X */ |
39 | GRN_TS_OP_NEGATIVE, /* -X */ |
40 | |
41 | /* Typecast operators. */ |
42 | GRN_TS_OP_FLOAT, |
43 | GRN_TS_OP_TIME, |
44 | |
45 | /* Binary operators. */ |
46 | GRN_TS_OP_LOGICAL_AND, /* X && Y */ |
47 | GRN_TS_OP_LOGICAL_OR, /* X || Y */ |
48 | GRN_TS_OP_LOGICAL_SUB, /* X &! Y */ |
49 | GRN_TS_OP_BITWISE_AND, /* X & Y */ |
50 | GRN_TS_OP_BITWISE_OR, /* X | Y */ |
51 | GRN_TS_OP_BITWISE_XOR, /* X ^ Y */ |
52 | GRN_TS_OP_EQUAL, /* X == Y */ |
53 | GRN_TS_OP_NOT_EQUAL, /* X != Y */ |
54 | GRN_TS_OP_LESS, /* X < Y */ |
55 | GRN_TS_OP_LESS_EQUAL, /* X <= Y */ |
56 | GRN_TS_OP_GREATER, /* X > Y */ |
57 | GRN_TS_OP_GREATER_EQUAL, /* X >= Y */ |
58 | GRN_TS_OP_SHIFT_ARITHMETIC_LEFT, /* X << Y */ |
59 | GRN_TS_OP_SHIFT_ARITHMETIC_RIGHT, /* X >> Y */ |
60 | GRN_TS_OP_SHIFT_LOGICAL_LEFT, /* X <<< Y */ |
61 | GRN_TS_OP_SHIFT_LOGICAL_RIGHT, /* X >>> Y */ |
62 | GRN_TS_OP_PLUS, /* X + Y */ |
63 | GRN_TS_OP_MINUS, /* X - Y */ |
64 | GRN_TS_OP_MULTIPLICATION, /* X * Y */ |
65 | GRN_TS_OP_DIVISION, /* X / Y */ |
66 | GRN_TS_OP_MODULUS, /* X % Y */ |
67 | GRN_TS_OP_MATCH, /* X @ Y */ |
68 | GRN_TS_OP_PREFIX_MATCH, /* X @^ Y */ |
69 | GRN_TS_OP_SUFFIX_MATCH /* X @$ Y */ |
70 | } grn_ts_op_type; |
71 | |
72 | /* Operator precedence. */ |
73 | typedef int grn_ts_op_precedence; |
74 | |
75 | /* grn_ts_op_get_n_args() returns the number of arguments. */ |
76 | size_t grn_ts_op_get_n_args(grn_ts_op_type op_type); |
77 | |
78 | /* |
79 | * grn_ts_op_get_precedence() returns the precedence. |
80 | * A prior operator has a higher precedence. |
81 | */ |
82 | grn_ts_op_precedence grn_ts_op_get_precedence(grn_ts_op_type op_type); |
83 | |
84 | #ifdef __cplusplus |
85 | } |
86 | #endif |
87 | |
88 | |