-
Notifications
You must be signed in to change notification settings - Fork 1
/
ewts-parser.h
306 lines (284 loc) · 3.13 KB
/
ewts-parser.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
/*
Declarations for the EWTS->Unicode parser.
Copyright (C) 2010 Elie Roux <elie.roux@telecom-bretagne.eu>
luaewts library loading file.
Copyright 2010 Elie Roux <elie.roux@telecom-bretagne.eu>
This file is under the Creative Commons CC0 license.
See the full text at
http://creativecommons.org/publicdomain/zero/1.0/legalcode
and a FAQ at
http://wiki.creativecommons.org/CC0
*/
#ifndef EWTS_PARSER_H
#define EWTS_PARSER_H
#include "ewts-common.h"
// the public function
char* ewts_scanner(const char *argstr);
// the state struct
typedef struct ewts_state {
char *utfbuf;
int utfbufindex;
unsigned char last_is_plus;
unsigned char current_state;
unsigned char last_stack_num;
unsigned char syllable_state;
unsigned char nb_vow;
} ewts_state;
// the different states
#define S_INITIAL 1
#define S_WAIT_CONS 2
#define S_END 3
// the prefixes: g, d, b, m and '
static char prefix[c_nb] = {0,
0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 1, 1, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0, 0};
// the suffixes: g ng d n b m r l s N T
static char suffix[c_nb] = {0,
0, 0, 1, 1, 0, 0, 0, 0, 0, 0,
1, 1, 0, 0, 1, 1, 0, 0, 0, 0,
0, 0, 0, 1, 1, 0, 1, 0, 0, 0,
0, 0, 0, 1, 0, 1, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0, 0};
static pwchar vowelchars[v_nb] = {0,
// v_a
0,
// v_i
0xf72,
// v_u
0xf74,
// v_e
0xf7a,
// v_o
0xf7c,
// v_ri
0xf76,
// v_li
0xf78,
// v_mini
0xf80,
// v_A
0xf71,
// v_I
0xf73,
// v_U
0xf75,
// v_ai
0xf7b,
// v_au
0xf7d,
// v_rI
0xf77,
// v_lI
0xf79,
// v_minI
0xf81,
};
static pwchar cons_initial[c_nb] = {0,
// c_k
L'ཀ',
// c_kh
L'ཁ',
// c_g
L'ག',
// c_ng
L'ང',
// c_c
L'ཅ',
// c_ch
L'ཆ',
// c_j
L'ཇ',
// c_ny
L'ཉ',
// c_t
L'ཏ',
// c_th
L'ཐ',
// c_d
L'ད',
// c_n
L'ན',
// c_p
L'པ',
// c_ph
L'ཕ',
// c_b
L'བ',
// c_m
L'མ',
// c_ts
L'ཙ',
// c_tsh
L'ཚ',
// c_dz
L'ཛ',
// c_w
L'ཝ',
// c_zh
L'ཞ',
// c_z
L'ཟ',
// c_y
L'ཡ',
// c_r
L'ར',
// c_l
L'ལ',
// c_sh
L'ཤ',
// c_s
L'ས',
// c_h
L'ཧ',
// c_none
L'ཨ',
// c_R
L'ཪ',
// c_D
L'ཌ',
// c_dh
L'དྷ',
// c_Dh
L'ཌྷ',
// c_T
L'ཊ',
// c_Th
L'ཋ',
// c_N
L'ཎ',
// c_Sh
L'ཥ',
// c_gh
L'གྷ',
// c_bh
L'བྷ',
// c_dzh
L'ཛྷ',
// c_apo
L'འ',
// c_kSh
L'ཀྵ',
// c_f
1,
// c_v
2,
// c_W
L'ཝ',
// c_Y
L'ཡ',
// c_OM
L'ༀ',
};
static pwchar cons_subjoined[c_nb] = {0,
// c_k
0xf90,
// c_kh
0xf91,
// c_g
0xf92,
// c_ng
0xf94,
// c_c
0xf95,
// c_ch
0xf96,
// c_j
0xf97,
// c_ny
0xf99,
// c_t
0xf9f,
// c_th
0xfa0,
// c_d
0xfa1,
// c_n
0xfa3,
// c_p
0xfa4,
// c_ph
0xfa5,
// c_b
0xfa6,
// c_m
0xfa8,
// c_ts
0xfa9,
// c_tsh
0xfaa,
// c_dz
0xfab,
// c_w
0xfad,
// c_zh
0xfae,
// c_z
0xfaf,
// c_y
0xfb1,
// c_r
0xfb2,
// c_l
0xfb3,
// c_sh
0xfb4,
// c_s
0xfb6,
// c_h
0xfb7,
// c_none
0xfb8,
// c_R
0xfbc,
// c_D
0xf9c,
// c_dh
0xfa2,
// c_Dh
0xf9d,
// c_T
0xf9a,
// c_Th
0xf9b,
// c_N
0xf9e,
// c_Sh
0xfb5,
// c_gh
0xf93,
// c_bh
0xfa7,
// c_dzh
0xfac,
// c_apo
0xfb0,
// c_kSh
0xfb9,
// c_f
0,
// c_v
0,
// c_W
0xfba,
// c_Y
0xfbb,
// c_OM
0,
};
// digits
static pwchar digchars[c_nb] = {
0xf20,
0xf21,
0xf22,
0xf23,
0xf24,
0xf25,
0xf26,
0xf27,
0xf28,
0xf29,
};
#endif