Debian Codegraph @

modules/lsp-runtime-lib/include/lsp-plug.in/expr/token.h

raw
1 /*
2 * Copyright (C) 2023 Linux Studio Plugins Project <https://lsp-plug.in/>
3 * (C) 2023 Vladimir Sadovnikov <[email protected]>
4 *
5 * This file is part of lsp-runtime-lib
6 * Created on: 16 сент. 2019 г.
7 *
8 * lsp-runtime-lib is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * any later version.
12 *
13 * lsp-runtime-lib is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with lsp-runtime-lib. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22 #ifndef LSP_PLUG_IN_EXPR_TOKEN_H_
23 #define LSP_PLUG_IN_EXPR_TOKEN_H_
24
25 #include <lsp-plug.in/runtime/version.h>
26 #include <lsp-plug.in/runtime/LSPString.h>
27
28 namespace lsp
29 {
30 namespace expr
31 {
32 enum token_t
33 {
34 TT_IDENTIFIER, // Identifier
35 TT_BAREWORD, // Bareword
36 TT_IVALUE, // Integer value
37 TT_FVALUE, // Floating-point value
38 TT_STRING, // String literal
39 TT_COLOR, // Color code: one of @HHSSLL, #RRGGBB
40
41 TT_LBRACE, // (
42 TT_RBRACE, // )
43 TT_LQBRACE, // [
44 TT_RQBRACE, // ]
45 TT_LCBRACE, // {
46 TT_RCBRACE, // }
47 TT_SHARP, // #
48 TT_AT, // @
49
50 // Constants
51 TT_TRUE, // true
52 TT_FALSE, // false
53 TT_NULL, // null
54 TT_UNDEF, // undef
55 TT_PI, // pi
56 TT_E, // e
57
58 // Logical operations
59 TT_AND, // &, &&, and
60 TT_OR, // |, ||, or
61 TT_NOT, // !, not
62 TT_XOR, // ^, ^^, xor
63
64 // Binary operations
65 TT_BAND, // band
66 TT_BOR, // bor
67 TT_BNOT, // ~, bnot
68 TT_BXOR, // bxor
69
70 // Floating-point operations
71 TT_ADD, // +
72 TT_SUB, // -
73 TT_ADDSYM, // add
74 TT_SUBSYM, // sub
75 TT_MUL, // *, mul
76 TT_POW, // **, pow
77 TT_DIV, // /, div
78 TT_FMOD, // fmod
79
80 // Integer operations
81 TT_IADD, // iadd
82 TT_ISUB, // isub
83 TT_IMUL, // imul
84 TT_IDIV, // idiv
85 TT_IMOD, // %, mod, imod
86
87 // Floating-point comparison
88 TT_LESS, // <, lt, nge
89 TT_GREATER, // >, gt, nle
90 TT_LESS_EQ, // <=, le, ngt
91 TT_GREATER_EQ, // >=, ge, nlt
92 TT_NOT_EQ, // !=, <>, ne
93 TT_EQ, // =, ==, eq
94 TT_CMP, // <=>, cmp
95
96 // Integer comparison
97 TT_ILESS, // ilt, inge
98 TT_IGREATER, // igt, inle
99 TT_ILESS_EQ, // ile, ingt
100 TT_IGREATER_EQ, // ige, ingt
101 TT_INOT_EQ, // ine
102 TT_IEQ, // ie, ieq
103 TT_ICMP, // icmp
104
105 // String operations
106 TT_SCAT, // String concat
107 TT_SREP, // String repeat
108 TT_SLEN, // String length
109 TT_SREV, // String reverse
110 TT_SUPR, // String upper
111 TT_SLWR, // String lower
112
113 // Casts
114 TT_INT, // Cast to integer
115 TT_FLOAT, // Cast to float
116 TT_STR, // Cast to string
117 TT_BOOL, // Cast to bool
118
119 // Math functions
120 TT_SIN, // Sine
121 TT_COS, // Cosine
122 TT_TAN, // Tangent
123 TT_ASIN, // Arcsine
124 TT_ACOS, // Arccosine
125 TT_ATAN, // Arctangent
126 TT_LOGE, // Natural logarithm
127 TT_LOGD, // Decimal logarithm
128 TT_LOG2, // Binary logarithm
129 TT_EXP, // Exponent
130 TT_SQRT, // Square root
131 TT_RAD, // Radians to degrees
132 TT_DEG, // Degrees to radians
133 TT_ABS, // Absolute value
134
135 // Misc operations
136 TT_EX, // ex
137
138 // Special measuring units
139 TT_DB, // db
140
141 // Different operators
142 TT_QUESTION, // ?
143 TT_COLON, // :
144 TT_SEMICOLON, // ;
145 TT_COMMA, // ,
146
147 // Control tokens
148 TT_UNKNOWN, // Unknown token
149 TT_EOF, // End of file reached
150 TT_ERROR // error
151 };
152
153 enum token_flags_t
154 {
155 TF_NONE = 0,
156 TF_GET = 1 << 0, // Get new token, don't return current
157 TF_XSIGN = 1 << 1, // Interpret sign as operator, not sign of numeric value
158 TF_BAREWORD = 1 << 2, // Treat barewords as identifiers
159 TF_XKEYWORDS = 1 << 3, // Exclude keywords, treat all keywords as TT_BAREWORD
160 TF_COLOR = 1 << 4 // Lookup for colors (@HSL and #RGB)
161 };
162 } /* namespace expr */
163 } /* namespace lsp */
164
165 #endif /* LSP_PLUG_IN_EXPR_TOKEN_H_ */