1 /* codescanner.c generated by valac, the Vala compiler
2 * generated from codescanner.vala, do not modify */
3
4 /* codescanner.vala
5 *
6 * Copyright (C) 2015 Florian Brosch
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library 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 GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 *
22 * Author:
23 * Florian Brosch <flo.brosch@gmail.com>
24 */
25
26 #include "valadoc.h"
27 #include <valagee.h>
28 #include <glib-object.h>
29 #include <stdlib.h>
30 #include <string.h>
31 #include <glib.h>
32
33 enum {
34 VALADOC_HIGHLIGHTER_CODE_SCANNER_0_PROPERTY,
35 VALADOC_HIGHLIGHTER_CODE_SCANNER_NUM_PROPERTIES
36 };
37 static GParamSpec* valadoc_highlighter_code_scanner_properties[VALADOC_HIGHLIGHTER_CODE_SCANNER_NUM_PROPERTIES];
38 typedef enum {
39 VALADOC_HIGHLIGHTER_CODE_SCANNER_NUMERIC_TYPE_INTEGER,
40 VALADOC_HIGHLIGHTER_CODE_SCANNER_NUMERIC_TYPE_REAL,
41 VALADOC_HIGHLIGHTER_CODE_SCANNER_NUMERIC_TYPE_NONE
42 } ValadocHighlighterCodeScannerNumericType;
43
44 #define VALADOC_HIGHLIGHTER_CODE_SCANNER_TYPE_NUMERIC_TYPE (valadoc_highlighter_code_scanner_numeric_type_get_type ())
45 #define _vala_map_unref0(var) ((var == NULL) ? NULL : (var = (vala_map_unref (var), NULL)))
46 #define _g_free0(var) ((var == NULL) ? NULL : (var = (g_free (var), NULL)))
47 #define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
48 #define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
49 #define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
50 #define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
51
52 struct _ValadocHighlighterCodeScannerPrivate {
53 ValaHashMap* keywords;
54 gboolean enable_string_templates;
55 gboolean enabel_verbatim_string;
56 gboolean enable_preprocessor_define;
57 gboolean enable_preprocessor_include;
58 gboolean enable_keyword_escape;
59 GQueue* token_queue;
60 const gchar* content;
61 const gchar* pos;
62 };
63
64 static gint ValadocHighlighterCodeScanner_private_offset;
65 static gpointer valadoc_highlighter_code_scanner_parent_class = NULL;
66 static ValadocHighlighterScannerIface * valadoc_highlighter_code_scanner_valadoc_highlighter_scanner_parent_iface = NULL;
67
68 static GType valadoc_highlighter_code_scanner_numeric_type_get_type (void) G_GNUC_CONST G_GNUC_UNUSED;
69 static void _valadoc_highlighter_code_token_unref0_ (gpointer var);
70 static inline void _g_queue_free__valadoc_highlighter_code_token_unref0_ (GQueue* self);
71 static ValadocHighlighterCodeToken* valadoc_highlighter_code_scanner_real_next (ValadocHighlighterScanner* base);
72 static gboolean valadoc_highlighter_code_scanner_queue_c_include (ValadocHighlighterCodeScanner* self);
73 static ValadocHighlighterCodeToken* valadoc_highlighter_code_scanner_dispatch (ValadocHighlighterCodeScanner* self,
74 const gchar* start,
75 const gchar* end);
76 static void valadoc_highlighter_code_scanner_queue_until (ValadocHighlighterCodeScanner* self,
77 gchar end_char,
78 ValadocHighlighterCodeTokenType token_type);
79 static void valadoc_highlighter_code_scanner_queue_string_literal (ValadocHighlighterCodeScanner* self,
80 const gchar* end_chars);
81 static void valadoc_highlighter_code_scanner_queue_numeric_literal (ValadocHighlighterCodeScanner* self);
82 static void valadoc_highlighter_code_scanner_queue_multiline_comment (ValadocHighlighterCodeScanner* self);
83 static inline gboolean valadoc_highlighter_code_scanner_isidstartchar (ValadocHighlighterCodeScanner* self,
84 gchar c);
85 static gboolean valadoc_highlighter_code_scanner_queue_keyword (ValadocHighlighterCodeScanner* self);
86 static gchar* _g_ascii_dup (gchar* self);
87 static void valadoc_highlighter_code_scanner_queue_token (ValadocHighlighterCodeScanner* self,
88 const gchar* start,
89 const gchar* end,
90 ValadocHighlighterCodeTokenType token_type);
91 static gboolean _g_ascii_equal (const gchar * s1,
92 const gchar * s2);
93 static inline gboolean valadoc_highlighter_code_scanner_isidchar (ValadocHighlighterCodeScanner* self,
94 gchar c);
95 static gboolean valadoc_highlighter_code_scanner_has_printf_format_prefix (ValadocHighlighterCodeScanner* self,
96 glong* skip);
97 static gboolean valadoc_highlighter_code_scanner_has_escape_prefix (ValadocHighlighterCodeScanner* self,
98 glong* skip);
99 static gboolean valadoc_highlighter_code_scanner_has_template_literal_prefix (ValadocHighlighterCodeScanner* self,
100 glong* skip);
101 static void valadoc_highlighter_code_scanner_finalize (GObject * obj);
102 static GType valadoc_highlighter_code_scanner_get_type_once (void);
103
104 static inline gpointer
valadoc_highlighter_code_scanner_get_instance_private(ValadocHighlighterCodeScanner * self)105 valadoc_highlighter_code_scanner_get_instance_private (ValadocHighlighterCodeScanner* self)
106 {
107 return G_STRUCT_MEMBER_P (self, ValadocHighlighterCodeScanner_private_offset);
108 }
109
110 static GType
valadoc_highlighter_code_scanner_numeric_type_get_type_once(void)111 valadoc_highlighter_code_scanner_numeric_type_get_type_once (void)
112 {
113 static const GEnumValue values[] = {{VALADOC_HIGHLIGHTER_CODE_SCANNER_NUMERIC_TYPE_INTEGER, "VALADOC_HIGHLIGHTER_CODE_SCANNER_NUMERIC_TYPE_INTEGER", "integer"}, {VALADOC_HIGHLIGHTER_CODE_SCANNER_NUMERIC_TYPE_REAL, "VALADOC_HIGHLIGHTER_CODE_SCANNER_NUMERIC_TYPE_REAL", "real"}, {VALADOC_HIGHLIGHTER_CODE_SCANNER_NUMERIC_TYPE_NONE, "VALADOC_HIGHLIGHTER_CODE_SCANNER_NUMERIC_TYPE_NONE", "none"}, {0, NULL, NULL}};
114 GType valadoc_highlighter_code_scanner_numeric_type_type_id;
115 valadoc_highlighter_code_scanner_numeric_type_type_id = g_enum_register_static ("ValadocHighlighterCodeScannerNumericType", values);
116 return valadoc_highlighter_code_scanner_numeric_type_type_id;
117 }
118
119 static GType
valadoc_highlighter_code_scanner_numeric_type_get_type(void)120 valadoc_highlighter_code_scanner_numeric_type_get_type (void)
121 {
122 static volatile gsize valadoc_highlighter_code_scanner_numeric_type_type_id__volatile = 0;
123 if (g_once_init_enter (&valadoc_highlighter_code_scanner_numeric_type_type_id__volatile)) {
124 GType valadoc_highlighter_code_scanner_numeric_type_type_id;
125 valadoc_highlighter_code_scanner_numeric_type_type_id = valadoc_highlighter_code_scanner_numeric_type_get_type_once ();
126 g_once_init_leave (&valadoc_highlighter_code_scanner_numeric_type_type_id__volatile, valadoc_highlighter_code_scanner_numeric_type_type_id);
127 }
128 return valadoc_highlighter_code_scanner_numeric_type_type_id__volatile;
129 }
130
131 static void
_valadoc_highlighter_code_token_unref0_(gpointer var)132 _valadoc_highlighter_code_token_unref0_ (gpointer var)
133 {
134 (var == NULL) ? NULL : (var = (valadoc_highlighter_code_token_unref (var), NULL));
135 }
136
137 static inline void
_g_queue_free__valadoc_highlighter_code_token_unref0_(GQueue * self)138 _g_queue_free__valadoc_highlighter_code_token_unref0_ (GQueue* self)
139 {
140 g_queue_free_full (self, (GDestroyNotify) _valadoc_highlighter_code_token_unref0_);
141 }
142
143 static gpointer
_vala_map_ref0(gpointer self)144 _vala_map_ref0 (gpointer self)
145 {
146 return self ? vala_map_ref (self) : NULL;
147 }
148
149 ValadocHighlighterCodeScanner*
valadoc_highlighter_code_scanner_construct(GType object_type,const gchar * content,gboolean enable_string_templates,gboolean enabel_verbatim_string,gboolean enable_preprocessor_define,gboolean enable_preprocessor_include,gboolean enable_keyword_escape,ValaHashMap * keywords)150 valadoc_highlighter_code_scanner_construct (GType object_type,
151 const gchar* content,
152 gboolean enable_string_templates,
153 gboolean enabel_verbatim_string,
154 gboolean enable_preprocessor_define,
155 gboolean enable_preprocessor_include,
156 gboolean enable_keyword_escape,
157 ValaHashMap* keywords)
158 {
159 ValadocHighlighterCodeScanner * self = NULL;
160 ValaHashMap* _tmp0_;
161 g_return_val_if_fail (content != NULL, NULL);
162 g_return_val_if_fail (keywords != NULL, NULL);
163 self = (ValadocHighlighterCodeScanner*) g_object_new (object_type, NULL);
164 self->priv->content = content;
165 self->priv->pos = content;
166 self->priv->enable_string_templates = enable_string_templates;
167 self->priv->enabel_verbatim_string = enabel_verbatim_string;
168 self->priv->enable_preprocessor_define = enable_preprocessor_define;
169 self->priv->enable_preprocessor_include = enable_preprocessor_include;
170 self->priv->enable_keyword_escape = enable_keyword_escape;
171 _tmp0_ = _vala_map_ref0 (keywords);
172 _vala_map_unref0 (self->priv->keywords);
173 self->priv->keywords = _tmp0_;
174 return self;
175 }
176
177 ValadocHighlighterCodeScanner*
valadoc_highlighter_code_scanner_new(const gchar * content,gboolean enable_string_templates,gboolean enabel_verbatim_string,gboolean enable_preprocessor_define,gboolean enable_preprocessor_include,gboolean enable_keyword_escape,ValaHashMap * keywords)178 valadoc_highlighter_code_scanner_new (const gchar* content,
179 gboolean enable_string_templates,
180 gboolean enabel_verbatim_string,
181 gboolean enable_preprocessor_define,
182 gboolean enable_preprocessor_include,
183 gboolean enable_keyword_escape,
184 ValaHashMap* keywords)
185 {
186 return valadoc_highlighter_code_scanner_construct (VALADOC_HIGHLIGHTER_TYPE_CODE_SCANNER, content, enable_string_templates, enabel_verbatim_string, enable_preprocessor_define, enable_preprocessor_include, enable_keyword_escape, keywords);
187 }
188
189 static gchar
string_get(const gchar * self,glong index)190 string_get (const gchar* self,
191 glong index)
192 {
193 gchar _tmp0_;
194 gchar result = '\0';
195 g_return_val_if_fail (self != NULL, '\0');
196 _tmp0_ = ((gchar*) self)[index];
197 result = _tmp0_;
198 return result;
199 }
200
201 static const gchar*
string_offset(const gchar * self,glong offset)202 string_offset (const gchar* self,
203 glong offset)
204 {
205 const gchar* result = NULL;
206 g_return_val_if_fail (self != NULL, NULL);
207 result = (const gchar*) (((gchar*) self) + offset);
208 return result;
209 }
210
211 static ValadocHighlighterCodeToken*
valadoc_highlighter_code_scanner_real_next(ValadocHighlighterScanner * base)212 valadoc_highlighter_code_scanner_real_next (ValadocHighlighterScanner* base)
213 {
214 ValadocHighlighterCodeScanner * self;
215 GQueue* _tmp0_;
216 const gchar* start = NULL;
217 GQueue* _tmp91_;
218 ValadocHighlighterCodeToken* _tmp92_;
219 const gchar* _tmp93_;
220 const gchar* _tmp94_;
221 ValadocHighlighterCodeToken* _tmp95_;
222 ValadocHighlighterCodeToken* result = NULL;
223 self = (ValadocHighlighterCodeScanner*) base;
224 _tmp0_ = self->priv->token_queue;
225 if (!g_queue_is_empty (_tmp0_)) {
226 GQueue* _tmp1_;
227 gpointer _tmp2_;
228 _tmp1_ = self->priv->token_queue;
229 _tmp2_ = g_queue_pop_head (_tmp1_);
230 result = (ValadocHighlighterCodeToken*) _tmp2_;
231 return result;
232 }
233 {
234 const gchar* _tmp3_;
235 gboolean _tmp4_ = FALSE;
236 _tmp3_ = self->priv->pos;
237 start = _tmp3_;
238 _tmp4_ = TRUE;
239 while (TRUE) {
240 const gchar* _tmp7_;
241 gboolean _tmp8_ = FALSE;
242 const gchar* _tmp9_;
243 const gchar* _tmp10_;
244 const gchar* _tmp44_;
245 gboolean _tmp49_ = FALSE;
246 const gchar* _tmp50_;
247 gboolean _tmp64_ = FALSE;
248 const gchar* _tmp65_;
249 const gchar* _tmp71_;
250 const gchar* _tmp76_;
251 gboolean _tmp81_ = FALSE;
252 gboolean _tmp82_ = FALSE;
253 const gchar* _tmp83_;
254 const gchar* _tmp84_;
255 if (!_tmp4_) {
256 const gchar* _tmp5_;
257 const gchar* _tmp6_;
258 _tmp5_ = self->priv->pos;
259 _tmp6_ = g_utf8_next_char (_tmp5_);
260 self->priv->pos = _tmp6_;
261 }
262 _tmp4_ = FALSE;
263 _tmp7_ = self->priv->pos;
264 if (!(string_get (_tmp7_, (glong) 0) != '\0')) {
265 break;
266 }
267 _tmp9_ = self->priv->pos;
268 _tmp10_ = self->priv->content;
269 if (((gchar*) _tmp9_) == ((gchar*) _tmp10_)) {
270 _tmp8_ = TRUE;
271 } else {
272 const gchar* _tmp11_;
273 _tmp11_ = self->priv->pos;
274 _tmp8_ = string_get (_tmp11_, (glong) 0) == '\n';
275 }
276 if (_tmp8_) {
277 const gchar* line_start = NULL;
278 const gchar* _tmp12_;
279 const gchar* _tmp20_;
280 _tmp12_ = self->priv->pos;
281 line_start = _tmp12_;
282 while (TRUE) {
283 gboolean _tmp13_ = FALSE;
284 gboolean _tmp14_ = FALSE;
285 const gchar* _tmp15_;
286 const gchar* _tmp18_;
287 const gchar* _tmp19_;
288 _tmp15_ = self->priv->pos;
289 if (string_get (_tmp15_, (glong) 0) == ' ') {
290 _tmp14_ = TRUE;
291 } else {
292 const gchar* _tmp16_;
293 _tmp16_ = self->priv->pos;
294 _tmp14_ = string_get (_tmp16_, (glong) 0) == '\t';
295 }
296 if (_tmp14_) {
297 _tmp13_ = TRUE;
298 } else {
299 const gchar* _tmp17_;
300 _tmp17_ = self->priv->pos;
301 _tmp13_ = string_get (_tmp17_, (glong) 0) == '\n';
302 }
303 if (!_tmp13_) {
304 break;
305 }
306 _tmp18_ = self->priv->pos;
307 _tmp19_ = string_offset (_tmp18_, (glong) 1);
308 self->priv->pos = _tmp19_;
309 }
310 _tmp20_ = self->priv->pos;
311 if (string_get (_tmp20_, (glong) 0) == '\0') {
312 break;
313 } else {
314 gboolean _tmp21_ = FALSE;
315 if (self->priv->enable_preprocessor_include) {
316 const gchar* _tmp22_;
317 _tmp22_ = self->priv->pos;
318 _tmp21_ = g_str_has_prefix (_tmp22_, "#include");
319 } else {
320 _tmp21_ = FALSE;
321 }
322 if (_tmp21_) {
323 const gchar* end = NULL;
324 const gchar* _tmp23_;
325 _tmp23_ = self->priv->pos;
326 end = _tmp23_;
327 if (valadoc_highlighter_code_scanner_queue_c_include (self)) {
328 const gchar* _tmp24_;
329 const gchar* _tmp25_;
330 ValadocHighlighterCodeToken* _tmp26_;
331 _tmp24_ = start;
332 _tmp25_ = end;
333 _tmp26_ = valadoc_highlighter_code_scanner_dispatch (self, _tmp24_, _tmp25_);
334 result = _tmp26_;
335 return result;
336 } else {
337 const gchar* _tmp27_;
338 _tmp27_ = line_start;
339 self->priv->pos = _tmp27_;
340 continue;
341 }
342 } else {
343 gboolean _tmp28_ = FALSE;
344 gboolean _tmp29_ = FALSE;
345 gboolean _tmp30_ = FALSE;
346 gboolean _tmp31_ = FALSE;
347 const gchar* _tmp32_;
348 _tmp32_ = self->priv->pos;
349 if (g_str_has_prefix (_tmp32_, "#if")) {
350 _tmp31_ = TRUE;
351 } else {
352 const gchar* _tmp33_;
353 _tmp33_ = self->priv->pos;
354 _tmp31_ = g_str_has_prefix (_tmp33_, "#else");
355 }
356 if (_tmp31_) {
357 _tmp30_ = TRUE;
358 } else {
359 const gchar* _tmp34_;
360 _tmp34_ = self->priv->pos;
361 _tmp30_ = g_str_has_prefix (_tmp34_, "#elif");
362 }
363 if (_tmp30_) {
364 _tmp29_ = TRUE;
365 } else {
366 const gchar* _tmp35_;
367 _tmp35_ = self->priv->pos;
368 _tmp29_ = g_str_has_prefix (_tmp35_, "#endif");
369 }
370 if (_tmp29_) {
371 _tmp28_ = TRUE;
372 } else {
373 gboolean _tmp36_ = FALSE;
374 if (self->priv->enable_preprocessor_define) {
375 gboolean _tmp37_ = FALSE;
376 const gchar* _tmp38_;
377 _tmp38_ = self->priv->pos;
378 if (g_str_has_prefix (_tmp38_, "#defined")) {
379 _tmp37_ = TRUE;
380 } else {
381 const gchar* _tmp39_;
382 _tmp39_ = self->priv->pos;
383 _tmp37_ = g_str_has_prefix (_tmp39_, "#ifdef");
384 }
385 _tmp36_ = _tmp37_;
386 } else {
387 _tmp36_ = FALSE;
388 }
389 _tmp28_ = _tmp36_;
390 }
391 if (_tmp28_) {
392 const gchar* end = NULL;
393 const gchar* _tmp40_;
394 const gchar* _tmp41_;
395 const gchar* _tmp42_;
396 ValadocHighlighterCodeToken* _tmp43_;
397 _tmp40_ = self->priv->pos;
398 end = _tmp40_;
399 valadoc_highlighter_code_scanner_queue_until (self, '\n', VALADOC_HIGHLIGHTER_CODE_TOKEN_TYPE_PREPROCESSOR);
400 _tmp41_ = start;
401 _tmp42_ = end;
402 _tmp43_ = valadoc_highlighter_code_scanner_dispatch (self, _tmp41_, _tmp42_);
403 result = _tmp43_;
404 return result;
405 }
406 }
407 }
408 }
409 _tmp44_ = self->priv->pos;
410 if (string_get (_tmp44_, (glong) 0) == '\'') {
411 const gchar* end = NULL;
412 const gchar* _tmp45_;
413 const gchar* _tmp46_;
414 const gchar* _tmp47_;
415 ValadocHighlighterCodeToken* _tmp48_;
416 _tmp45_ = self->priv->pos;
417 end = _tmp45_;
418 valadoc_highlighter_code_scanner_queue_string_literal (self, "\'");
419 _tmp46_ = start;
420 _tmp47_ = end;
421 _tmp48_ = valadoc_highlighter_code_scanner_dispatch (self, _tmp46_, _tmp47_);
422 result = _tmp48_;
423 return result;
424 }
425 _tmp50_ = self->priv->pos;
426 if (string_get (_tmp50_, (glong) 0) == '"') {
427 _tmp49_ = TRUE;
428 } else {
429 gboolean _tmp51_ = FALSE;
430 gboolean _tmp52_ = FALSE;
431 if (self->priv->enable_string_templates) {
432 const gchar* _tmp53_;
433 _tmp53_ = self->priv->pos;
434 _tmp52_ = string_get (_tmp53_, (glong) 0) == '@';
435 } else {
436 _tmp52_ = FALSE;
437 }
438 if (_tmp52_) {
439 const gchar* _tmp54_;
440 _tmp54_ = self->priv->pos;
441 _tmp51_ = string_get (_tmp54_, (glong) 1) == '"';
442 } else {
443 _tmp51_ = FALSE;
444 }
445 _tmp49_ = _tmp51_;
446 }
447 if (_tmp49_) {
448 const gchar* end = NULL;
449 const gchar* _tmp55_;
450 gboolean _tmp56_ = FALSE;
451 const gchar* _tmp61_;
452 const gchar* _tmp62_;
453 ValadocHighlighterCodeToken* _tmp63_;
454 _tmp55_ = self->priv->pos;
455 end = _tmp55_;
456 if (self->priv->enabel_verbatim_string) {
457 gboolean _tmp57_ = FALSE;
458 const gchar* _tmp58_;
459 _tmp58_ = self->priv->pos;
460 if (g_str_has_prefix (_tmp58_, "\"\"\"")) {
461 _tmp57_ = TRUE;
462 } else {
463 gboolean _tmp59_ = FALSE;
464 if (self->priv->enable_string_templates) {
465 const gchar* _tmp60_;
466 _tmp60_ = self->priv->pos;
467 _tmp59_ = g_str_has_prefix (_tmp60_, "@\"\"\"");
468 } else {
469 _tmp59_ = FALSE;
470 }
471 _tmp57_ = _tmp59_;
472 }
473 _tmp56_ = _tmp57_;
474 } else {
475 _tmp56_ = FALSE;
476 }
477 if (_tmp56_) {
478 valadoc_highlighter_code_scanner_queue_string_literal (self, "\"\"\"");
479 } else {
480 valadoc_highlighter_code_scanner_queue_string_literal (self, "\"");
481 }
482 _tmp61_ = start;
483 _tmp62_ = end;
484 _tmp63_ = valadoc_highlighter_code_scanner_dispatch (self, _tmp61_, _tmp62_);
485 result = _tmp63_;
486 return result;
487 }
488 _tmp65_ = self->priv->pos;
489 if (string_get (_tmp65_, (glong) 0) >= '0') {
490 const gchar* _tmp66_;
491 _tmp66_ = self->priv->pos;
492 _tmp64_ = string_get (_tmp66_, (glong) 0) <= '9';
493 } else {
494 _tmp64_ = FALSE;
495 }
496 if (_tmp64_) {
497 const gchar* end = NULL;
498 const gchar* _tmp67_;
499 const gchar* _tmp68_;
500 const gchar* _tmp69_;
501 ValadocHighlighterCodeToken* _tmp70_;
502 _tmp67_ = self->priv->pos;
503 end = _tmp67_;
504 valadoc_highlighter_code_scanner_queue_numeric_literal (self);
505 _tmp68_ = start;
506 _tmp69_ = end;
507 _tmp70_ = valadoc_highlighter_code_scanner_dispatch (self, _tmp68_, _tmp69_);
508 result = _tmp70_;
509 return result;
510 }
511 _tmp71_ = self->priv->pos;
512 if (g_str_has_prefix (_tmp71_, "/*")) {
513 const gchar* end = NULL;
514 const gchar* _tmp72_;
515 const gchar* _tmp73_;
516 const gchar* _tmp74_;
517 ValadocHighlighterCodeToken* _tmp75_;
518 _tmp72_ = self->priv->pos;
519 end = _tmp72_;
520 valadoc_highlighter_code_scanner_queue_multiline_comment (self);
521 _tmp73_ = start;
522 _tmp74_ = end;
523 _tmp75_ = valadoc_highlighter_code_scanner_dispatch (self, _tmp73_, _tmp74_);
524 result = _tmp75_;
525 return result;
526 }
527 _tmp76_ = self->priv->pos;
528 if (g_str_has_prefix (_tmp76_, "//")) {
529 const gchar* end = NULL;
530 const gchar* _tmp77_;
531 const gchar* _tmp78_;
532 const gchar* _tmp79_;
533 ValadocHighlighterCodeToken* _tmp80_;
534 _tmp77_ = self->priv->pos;
535 end = _tmp77_;
536 valadoc_highlighter_code_scanner_queue_until (self, '\n', VALADOC_HIGHLIGHTER_CODE_TOKEN_TYPE_COMMENT);
537 _tmp78_ = start;
538 _tmp79_ = end;
539 _tmp80_ = valadoc_highlighter_code_scanner_dispatch (self, _tmp78_, _tmp79_);
540 result = _tmp80_;
541 return result;
542 }
543 _tmp83_ = self->priv->pos;
544 _tmp84_ = self->priv->content;
545 if (((gchar*) _tmp83_) == ((gchar*) _tmp84_)) {
546 _tmp82_ = TRUE;
547 } else {
548 const gchar* _tmp85_;
549 _tmp85_ = self->priv->pos;
550 _tmp82_ = !valadoc_highlighter_code_scanner_isidstartchar (self, string_get (_tmp85_, (glong) -1));
551 }
552 if (_tmp82_) {
553 const gchar* _tmp86_;
554 _tmp86_ = self->priv->pos;
555 _tmp81_ = valadoc_highlighter_code_scanner_isidstartchar (self, string_get (_tmp86_, (glong) 0));
556 } else {
557 _tmp81_ = FALSE;
558 }
559 if (_tmp81_) {
560 const gchar* end = NULL;
561 const gchar* _tmp87_;
562 _tmp87_ = self->priv->pos;
563 end = _tmp87_;
564 if (valadoc_highlighter_code_scanner_queue_keyword (self)) {
565 const gchar* _tmp88_;
566 const gchar* _tmp89_;
567 ValadocHighlighterCodeToken* _tmp90_;
568 _tmp88_ = start;
569 _tmp89_ = end;
570 _tmp90_ = valadoc_highlighter_code_scanner_dispatch (self, _tmp88_, _tmp89_);
571 result = _tmp90_;
572 return result;
573 } else {
574 continue;
575 }
576 }
577 }
578 }
579 _tmp91_ = self->priv->token_queue;
580 _tmp92_ = valadoc_highlighter_code_token_new (VALADOC_HIGHLIGHTER_CODE_TOKEN_TYPE_EOF, "");
581 g_queue_push_tail (_tmp91_, _tmp92_);
582 _tmp93_ = start;
583 _tmp94_ = self->priv->pos;
584 _tmp95_ = valadoc_highlighter_code_scanner_dispatch (self, _tmp93_, _tmp94_);
585 result = _tmp95_;
586 return result;
587 }
588
589 static gchar*
_g_ascii_dup(gchar * self)590 _g_ascii_dup (gchar* self)
591 {
592 gchar* dup;
593 dup = g_new0 (gchar, 1);
594 memcpy (dup, self, sizeof (gchar));
595 return dup;
596 }
597
598 static gpointer
__g_ascii_dup0(gpointer self)599 __g_ascii_dup0 (gpointer self)
600 {
601 return self ? _g_ascii_dup (self) : NULL;
602 }
603
604 static gboolean
_g_ascii_equal(const gchar * s1,const gchar * s2)605 _g_ascii_equal (const gchar * s1,
606 const gchar * s2)
607 {
608 if (s1 == s2) {
609 return TRUE;
610 }
611 if (s1 == NULL) {
612 return FALSE;
613 }
614 if (s2 == NULL) {
615 return FALSE;
616 }
617 return (*s1) == (*s2);
618 }
619
620 static gboolean
valadoc_highlighter_code_scanner_queue_c_include(ValadocHighlighterCodeScanner * self)621 valadoc_highlighter_code_scanner_queue_c_include (ValadocHighlighterCodeScanner* self)
622 {
623 const gchar* include_start = NULL;
624 const gchar* _tmp0_;
625 const gchar* start = NULL;
626 const gchar* _tmp1_;
627 const gchar* _tmp2_;
628 const gchar* _tmp3_;
629 gchar* end_char = NULL;
630 const gchar* _tmp9_;
631 gchar* _tmp15_;
632 gboolean _tmp45_ = FALSE;
633 const gchar* _tmp46_;
634 gboolean result = FALSE;
635 g_return_val_if_fail (self != NULL, FALSE);
636 _tmp0_ = self->priv->pos;
637 include_start = _tmp0_;
638 _tmp1_ = self->priv->pos;
639 start = _tmp1_;
640 _tmp2_ = self->priv->pos;
641 _tmp3_ = string_offset (_tmp2_, (glong) 8);
642 self->priv->pos = _tmp3_;
643 while (TRUE) {
644 gboolean _tmp4_ = FALSE;
645 const gchar* _tmp5_;
646 const gchar* _tmp7_;
647 const gchar* _tmp8_;
648 _tmp5_ = self->priv->pos;
649 if (string_get (_tmp5_, (glong) 0) == ' ') {
650 _tmp4_ = TRUE;
651 } else {
652 const gchar* _tmp6_;
653 _tmp6_ = self->priv->pos;
654 _tmp4_ = string_get (_tmp6_, (glong) 0) == '\t';
655 }
656 if (!_tmp4_) {
657 break;
658 }
659 _tmp7_ = self->priv->pos;
660 _tmp8_ = string_offset (_tmp7_, (glong) 1);
661 self->priv->pos = _tmp8_;
662 }
663 end_char = NULL;
664 _tmp9_ = self->priv->pos;
665 if (string_get (_tmp9_, (glong) 0) == '"') {
666 gchar _tmp10_;
667 gchar* _tmp11_;
668 _tmp10_ = '"';
669 _tmp11_ = __g_ascii_dup0 (&_tmp10_);
670 _g_free0 (end_char);
671 end_char = _tmp11_;
672 } else {
673 const gchar* _tmp12_;
674 _tmp12_ = self->priv->pos;
675 if (string_get (_tmp12_, (glong) 0) == '<') {
676 gchar _tmp13_;
677 gchar* _tmp14_;
678 _tmp13_ = '>';
679 _tmp14_ = __g_ascii_dup0 (&_tmp13_);
680 _g_free0 (end_char);
681 end_char = _tmp14_;
682 }
683 }
684 _tmp15_ = end_char;
685 if (_tmp15_ != NULL) {
686 const gchar* _tmp16_;
687 const gchar* _tmp17_;
688 const gchar* literal_start = NULL;
689 const gchar* _tmp18_;
690 const gchar* _tmp19_;
691 const gchar* _tmp20_;
692 const gchar* _tmp30_;
693 gchar _tmp31_;
694 gchar* _tmp32_;
695 _tmp16_ = start;
696 _tmp17_ = self->priv->pos;
697 valadoc_highlighter_code_scanner_queue_token (self, _tmp16_, _tmp17_, VALADOC_HIGHLIGHTER_CODE_TOKEN_TYPE_PREPROCESSOR);
698 _tmp18_ = self->priv->pos;
699 literal_start = _tmp18_;
700 _tmp19_ = self->priv->pos;
701 _tmp20_ = string_offset (_tmp19_, (glong) 1);
702 self->priv->pos = _tmp20_;
703 while (TRUE) {
704 gboolean _tmp21_ = FALSE;
705 gboolean _tmp22_ = FALSE;
706 const gchar* _tmp23_;
707 gchar _tmp24_;
708 gchar* _tmp25_;
709 const gchar* _tmp28_;
710 const gchar* _tmp29_;
711 _tmp23_ = self->priv->pos;
712 _tmp24_ = string_get (_tmp23_, (glong) 0);
713 _tmp25_ = end_char;
714 if (_g_ascii_equal (&_tmp24_, _tmp25_) != TRUE) {
715 const gchar* _tmp26_;
716 _tmp26_ = self->priv->pos;
717 _tmp22_ = string_get (_tmp26_, (glong) 0) != '\n';
718 } else {
719 _tmp22_ = FALSE;
720 }
721 if (_tmp22_) {
722 const gchar* _tmp27_;
723 _tmp27_ = self->priv->pos;
724 _tmp21_ = string_get (_tmp27_, (glong) 0) != '\0';
725 } else {
726 _tmp21_ = FALSE;
727 }
728 if (!_tmp21_) {
729 break;
730 }
731 _tmp28_ = self->priv->pos;
732 _tmp29_ = string_offset (_tmp28_, (glong) 1);
733 self->priv->pos = _tmp29_;
734 }
735 _tmp30_ = self->priv->pos;
736 _tmp31_ = string_get (_tmp30_, (glong) 0);
737 _tmp32_ = end_char;
738 if (_g_ascii_equal (&_tmp31_, _tmp32_) == TRUE) {
739 const gchar* _tmp33_;
740 const gchar* _tmp34_;
741 const gchar* _tmp35_;
742 const gchar* _tmp36_;
743 const gchar* _tmp37_;
744 _tmp33_ = self->priv->pos;
745 _tmp34_ = string_offset (_tmp33_, (glong) 1);
746 self->priv->pos = _tmp34_;
747 _tmp35_ = literal_start;
748 _tmp36_ = self->priv->pos;
749 valadoc_highlighter_code_scanner_queue_token (self, _tmp35_, _tmp36_, VALADOC_HIGHLIGHTER_CODE_TOKEN_TYPE_LITERAL);
750 _tmp37_ = self->priv->pos;
751 start = _tmp37_;
752 } else {
753 const gchar* _tmp38_;
754 GQueue* _tmp39_;
755 _tmp38_ = include_start;
756 self->priv->pos = _tmp38_;
757 _tmp39_ = self->priv->token_queue;
758 g_queue_clear (_tmp39_);
759 result = FALSE;
760 _g_free0 (end_char);
761 return result;
762 }
763 }
764 while (TRUE) {
765 gboolean _tmp40_ = FALSE;
766 const gchar* _tmp41_;
767 const gchar* _tmp43_;
768 const gchar* _tmp44_;
769 _tmp41_ = self->priv->pos;
770 if (string_get (_tmp41_, (glong) 0) == ' ') {
771 _tmp40_ = TRUE;
772 } else {
773 const gchar* _tmp42_;
774 _tmp42_ = self->priv->pos;
775 _tmp40_ = string_get (_tmp42_, (glong) 0) == '\t';
776 }
777 if (!_tmp40_) {
778 break;
779 }
780 _tmp43_ = self->priv->pos;
781 _tmp44_ = string_offset (_tmp43_, (glong) 1);
782 self->priv->pos = _tmp44_;
783 }
784 _tmp46_ = self->priv->pos;
785 if (string_get (_tmp46_, (glong) 0) == '\n') {
786 _tmp45_ = TRUE;
787 } else {
788 const gchar* _tmp47_;
789 _tmp47_ = self->priv->pos;
790 _tmp45_ = string_get (_tmp47_, (glong) 0) == '\0';
791 }
792 if (_tmp45_) {
793 const gchar* _tmp48_;
794 const gchar* _tmp49_;
795 _tmp48_ = start;
796 _tmp49_ = self->priv->pos;
797 valadoc_highlighter_code_scanner_queue_token (self, _tmp48_, _tmp49_, VALADOC_HIGHLIGHTER_CODE_TOKEN_TYPE_PREPROCESSOR);
798 result = TRUE;
799 _g_free0 (end_char);
800 return result;
801 } else {
802 const gchar* _tmp50_;
803 GQueue* _tmp51_;
804 _tmp50_ = include_start;
805 self->priv->pos = _tmp50_;
806 _tmp51_ = self->priv->token_queue;
807 g_queue_clear (_tmp51_);
808 result = FALSE;
809 _g_free0 (end_char);
810 return result;
811 }
812 _g_free0 (end_char);
813 }
814
815 static glong
string_pointer_to_offset(const gchar * self,const gchar * pos)816 string_pointer_to_offset (const gchar* self,
817 const gchar* pos)
818 {
819 glong result = 0L;
820 g_return_val_if_fail (self != NULL, 0L);
821 g_return_val_if_fail (pos != NULL, 0L);
822 result = (glong) (((gchar*) pos) - ((gchar*) self));
823 return result;
824 }
825
826 static glong
string_strnlen(gchar * str,glong maxlen)827 string_strnlen (gchar* str,
828 glong maxlen)
829 {
830 gchar* end = NULL;
831 gchar* _tmp0_;
832 gchar* _tmp1_;
833 glong result = 0L;
834 _tmp0_ = memchr (str, 0, (gsize) maxlen);
835 end = _tmp0_;
836 _tmp1_ = end;
837 if (_tmp1_ == NULL) {
838 result = maxlen;
839 return result;
840 } else {
841 gchar* _tmp2_;
842 _tmp2_ = end;
843 result = (glong) (_tmp2_ - str);
844 return result;
845 }
846 }
847
848 static gchar*
string_substring(const gchar * self,glong offset,glong len)849 string_substring (const gchar* self,
850 glong offset,
851 glong len)
852 {
853 glong string_length = 0L;
854 gboolean _tmp0_ = FALSE;
855 gchar* _tmp3_;
856 gchar* result = NULL;
857 g_return_val_if_fail (self != NULL, NULL);
858 if (offset >= ((glong) 0)) {
859 _tmp0_ = len >= ((glong) 0);
860 } else {
861 _tmp0_ = FALSE;
862 }
863 if (_tmp0_) {
864 string_length = string_strnlen ((gchar*) self, offset + len);
865 } else {
866 gint _tmp1_;
867 gint _tmp2_;
868 _tmp1_ = strlen (self);
869 _tmp2_ = _tmp1_;
870 string_length = (glong) _tmp2_;
871 }
872 if (offset < ((glong) 0)) {
873 offset = string_length + offset;
874 g_return_val_if_fail (offset >= ((glong) 0), NULL);
875 } else {
876 g_return_val_if_fail (offset <= string_length, NULL);
877 }
878 if (len < ((glong) 0)) {
879 len = string_length - offset;
880 }
881 g_return_val_if_fail ((offset + len) <= string_length, NULL);
882 _tmp3_ = g_strndup (((gchar*) self) + offset, (gsize) len);
883 result = _tmp3_;
884 return result;
885 }
886
887 static gboolean
valadoc_highlighter_code_scanner_queue_keyword(ValadocHighlighterCodeScanner * self)888 valadoc_highlighter_code_scanner_queue_keyword (ValadocHighlighterCodeScanner* self)
889 {
890 const gchar* start = NULL;
891 const gchar* _tmp0_;
892 const gchar* _tmp1_;
893 glong length = 0L;
894 const gchar* _tmp7_;
895 const gchar* _tmp8_;
896 gchar* word = NULL;
897 const gchar* _tmp9_;
898 gchar* _tmp10_;
899 ValadocHighlighterCodeTokenType* token_type = NULL;
900 ValaHashMap* _tmp11_;
901 const gchar* _tmp12_;
902 gpointer _tmp13_;
903 ValadocHighlighterCodeTokenType* _tmp14_;
904 GQueue* _tmp16_;
905 ValadocHighlighterCodeTokenType* _tmp17_;
906 const gchar* _tmp18_;
907 ValadocHighlighterCodeToken* _tmp19_;
908 gboolean result = FALSE;
909 g_return_val_if_fail (self != NULL, FALSE);
910 _tmp0_ = self->priv->pos;
911 start = _tmp0_;
912 _tmp1_ = self->priv->pos;
913 if (string_get (_tmp1_, (glong) 0) == '@') {
914 const gchar* _tmp2_;
915 const gchar* _tmp3_;
916 _tmp2_ = self->priv->pos;
917 _tmp3_ = string_offset (_tmp2_, (glong) 1);
918 self->priv->pos = _tmp3_;
919 }
920 while (TRUE) {
921 const gchar* _tmp4_;
922 const gchar* _tmp5_;
923 const gchar* _tmp6_;
924 _tmp4_ = self->priv->pos;
925 if (!valadoc_highlighter_code_scanner_isidchar (self, string_get (_tmp4_, (glong) 0))) {
926 break;
927 }
928 _tmp5_ = self->priv->pos;
929 _tmp6_ = string_offset (_tmp5_, (glong) 1);
930 self->priv->pos = _tmp6_;
931 }
932 _tmp7_ = start;
933 _tmp8_ = self->priv->pos;
934 length = string_pointer_to_offset (_tmp7_, _tmp8_);
935 _tmp9_ = start;
936 _tmp10_ = string_substring (_tmp9_, (glong) 0, length);
937 word = _tmp10_;
938 _tmp11_ = self->priv->keywords;
939 _tmp12_ = word;
940 _tmp13_ = vala_map_get ((ValaMap*) _tmp11_, _tmp12_);
941 token_type = (ValadocHighlighterCodeTokenType*) _tmp13_;
942 _tmp14_ = token_type;
943 if (_tmp14_ == NULL) {
944 const gchar* _tmp15_;
945 _tmp15_ = start;
946 self->priv->pos = _tmp15_;
947 result = FALSE;
948 _g_free0 (token_type);
949 _g_free0 (word);
950 return result;
951 }
952 _tmp16_ = self->priv->token_queue;
953 _tmp17_ = token_type;
954 _tmp18_ = word;
955 _tmp19_ = valadoc_highlighter_code_token_new (*_tmp17_, _tmp18_);
956 g_queue_push_tail (_tmp16_, _tmp19_);
957 result = TRUE;
958 _g_free0 (token_type);
959 _g_free0 (word);
960 return result;
961 }
962
963 static void
valadoc_highlighter_code_scanner_queue_multiline_comment(ValadocHighlighterCodeScanner * self)964 valadoc_highlighter_code_scanner_queue_multiline_comment (ValadocHighlighterCodeScanner* self)
965 {
966 const gchar* start = NULL;
967 const gchar* _tmp0_;
968 const gchar* _tmp1_;
969 const gchar* _tmp2_;
970 const gchar* _tmp10_;
971 const gchar* _tmp13_;
972 const gchar* _tmp14_;
973 g_return_if_fail (self != NULL);
974 _tmp0_ = self->priv->pos;
975 start = _tmp0_;
976 _tmp1_ = self->priv->pos;
977 _tmp2_ = string_offset (_tmp1_, (glong) 2);
978 self->priv->pos = _tmp2_;
979 while (TRUE) {
980 gboolean _tmp3_ = FALSE;
981 gboolean _tmp4_ = FALSE;
982 const gchar* _tmp5_;
983 const gchar* _tmp8_;
984 const gchar* _tmp9_;
985 _tmp5_ = self->priv->pos;
986 if (string_get (_tmp5_, (glong) 0) == '*') {
987 const gchar* _tmp6_;
988 _tmp6_ = self->priv->pos;
989 _tmp4_ = string_get (_tmp6_, (glong) 1) == '/';
990 } else {
991 _tmp4_ = FALSE;
992 }
993 if (!_tmp4_) {
994 const gchar* _tmp7_;
995 _tmp7_ = self->priv->pos;
996 _tmp3_ = string_get (_tmp7_, (glong) 0) != '\0';
997 } else {
998 _tmp3_ = FALSE;
999 }
1000 if (!_tmp3_) {
1001 break;
1002 }
1003 _tmp8_ = self->priv->pos;
1004 _tmp9_ = string_offset (_tmp8_, (glong) 1);
1005 self->priv->pos = _tmp9_;
1006 }
1007 _tmp10_ = self->priv->pos;
1008 if (string_get (_tmp10_, (glong) 0) != '\0') {
1009 const gchar* _tmp11_;
1010 const gchar* _tmp12_;
1011 _tmp11_ = self->priv->pos;
1012 _tmp12_ = string_offset (_tmp11_, (glong) 2);
1013 self->priv->pos = _tmp12_;
1014 }
1015 _tmp13_ = start;
1016 _tmp14_ = self->priv->pos;
1017 valadoc_highlighter_code_scanner_queue_token (self, _tmp13_, _tmp14_, VALADOC_HIGHLIGHTER_CODE_TOKEN_TYPE_COMMENT);
1018 }
1019
1020 static void
valadoc_highlighter_code_scanner_queue_until(ValadocHighlighterCodeScanner * self,gchar end_char,ValadocHighlighterCodeTokenType token_type)1021 valadoc_highlighter_code_scanner_queue_until (ValadocHighlighterCodeScanner* self,
1022 gchar end_char,
1023 ValadocHighlighterCodeTokenType token_type)
1024 {
1025 const gchar* start = NULL;
1026 const gchar* _tmp0_;
1027 const gchar* _tmp1_;
1028 const gchar* _tmp2_;
1029 gboolean _tmp8_ = FALSE;
1030 const gchar* _tmp9_;
1031 const gchar* _tmp13_;
1032 const gchar* _tmp14_;
1033 g_return_if_fail (self != NULL);
1034 _tmp0_ = self->priv->pos;
1035 start = _tmp0_;
1036 _tmp1_ = self->priv->pos;
1037 _tmp2_ = string_offset (_tmp1_, (glong) 1);
1038 self->priv->pos = _tmp2_;
1039 while (TRUE) {
1040 gboolean _tmp3_ = FALSE;
1041 const gchar* _tmp4_;
1042 const gchar* _tmp6_;
1043 const gchar* _tmp7_;
1044 _tmp4_ = self->priv->pos;
1045 if (string_get (_tmp4_, (glong) 0) != end_char) {
1046 const gchar* _tmp5_;
1047 _tmp5_ = self->priv->pos;
1048 _tmp3_ = string_get (_tmp5_, (glong) 0) != '\0';
1049 } else {
1050 _tmp3_ = FALSE;
1051 }
1052 if (!_tmp3_) {
1053 break;
1054 }
1055 _tmp6_ = self->priv->pos;
1056 _tmp7_ = string_offset (_tmp6_, (glong) 1);
1057 self->priv->pos = _tmp7_;
1058 }
1059 _tmp9_ = self->priv->pos;
1060 if (string_get (_tmp9_, (glong) 0) != '\0') {
1061 const gchar* _tmp10_;
1062 _tmp10_ = self->priv->pos;
1063 _tmp8_ = string_get (_tmp10_, (glong) 0) != '\n';
1064 } else {
1065 _tmp8_ = FALSE;
1066 }
1067 if (_tmp8_) {
1068 const gchar* _tmp11_;
1069 const gchar* _tmp12_;
1070 _tmp11_ = self->priv->pos;
1071 _tmp12_ = string_offset (_tmp11_, (glong) 1);
1072 self->priv->pos = _tmp12_;
1073 }
1074 _tmp13_ = start;
1075 _tmp14_ = self->priv->pos;
1076 valadoc_highlighter_code_scanner_queue_token (self, _tmp13_, _tmp14_, token_type);
1077 }
1078
1079 static void
valadoc_highlighter_code_scanner_queue_string_literal(ValadocHighlighterCodeScanner * self,const gchar * end_chars)1080 valadoc_highlighter_code_scanner_queue_string_literal (ValadocHighlighterCodeScanner* self,
1081 const gchar* end_chars)
1082 {
1083 const gchar* start = NULL;
1084 const gchar* _tmp0_;
1085 gboolean is_template = FALSE;
1086 const gchar* _tmp1_;
1087 const gchar* _tmp38_;
1088 const gchar* _tmp43_;
1089 const gchar* _tmp44_;
1090 g_return_if_fail (self != NULL);
1091 g_return_if_fail (end_chars != NULL);
1092 _tmp0_ = self->priv->pos;
1093 start = _tmp0_;
1094 is_template = FALSE;
1095 _tmp1_ = self->priv->pos;
1096 if (string_get (_tmp1_, (glong) 0) == '@') {
1097 const gchar* _tmp2_;
1098 gint _tmp3_;
1099 gint _tmp4_;
1100 const gchar* _tmp5_;
1101 _tmp2_ = self->priv->pos;
1102 _tmp3_ = strlen (end_chars);
1103 _tmp4_ = _tmp3_;
1104 _tmp5_ = string_offset (_tmp2_, (glong) (_tmp4_ + 1));
1105 self->priv->pos = _tmp5_;
1106 is_template = TRUE;
1107 } else {
1108 const gchar* _tmp6_;
1109 gint _tmp7_;
1110 gint _tmp8_;
1111 const gchar* _tmp9_;
1112 _tmp6_ = self->priv->pos;
1113 _tmp7_ = strlen (end_chars);
1114 _tmp8_ = _tmp7_;
1115 _tmp9_ = string_offset (_tmp6_, (glong) _tmp8_);
1116 self->priv->pos = _tmp9_;
1117 }
1118 while (TRUE) {
1119 gboolean _tmp10_ = FALSE;
1120 const gchar* _tmp11_;
1121 glong skip = 0L;
1122 gboolean _tmp13_ = FALSE;
1123 gboolean _tmp14_ = FALSE;
1124 gboolean _tmp15_ = FALSE;
1125 const gchar* _tmp16_;
1126 _tmp11_ = self->priv->pos;
1127 if (!g_str_has_prefix (_tmp11_, end_chars)) {
1128 const gchar* _tmp12_;
1129 _tmp12_ = self->priv->pos;
1130 _tmp10_ = string_get (_tmp12_, (glong) 0) != '\0';
1131 } else {
1132 _tmp10_ = FALSE;
1133 }
1134 if (!_tmp10_) {
1135 break;
1136 }
1137 skip = (glong) 0;
1138 _tmp16_ = self->priv->pos;
1139 if (string_get (_tmp16_, (glong) 0) == '%') {
1140 glong _tmp17_ = 0L;
1141 gboolean _tmp18_;
1142 _tmp18_ = valadoc_highlighter_code_scanner_has_printf_format_prefix (self, &_tmp17_);
1143 skip = _tmp17_;
1144 _tmp15_ = _tmp18_;
1145 } else {
1146 _tmp15_ = FALSE;
1147 }
1148 if (_tmp15_) {
1149 _tmp14_ = TRUE;
1150 } else {
1151 gboolean _tmp19_ = FALSE;
1152 const gchar* _tmp20_;
1153 _tmp20_ = self->priv->pos;
1154 if (string_get (_tmp20_, (glong) 0) == '\\') {
1155 glong _tmp21_ = 0L;
1156 gboolean _tmp22_;
1157 _tmp22_ = valadoc_highlighter_code_scanner_has_escape_prefix (self, &_tmp21_);
1158 skip = _tmp21_;
1159 _tmp19_ = _tmp22_;
1160 } else {
1161 _tmp19_ = FALSE;
1162 }
1163 _tmp14_ = _tmp19_;
1164 }
1165 if (_tmp14_) {
1166 _tmp13_ = TRUE;
1167 } else {
1168 gboolean _tmp23_ = FALSE;
1169 gboolean _tmp24_ = FALSE;
1170 if (is_template) {
1171 const gchar* _tmp25_;
1172 _tmp25_ = self->priv->pos;
1173 _tmp24_ = string_get (_tmp25_, (glong) 0) == '$';
1174 } else {
1175 _tmp24_ = FALSE;
1176 }
1177 if (_tmp24_) {
1178 glong _tmp26_ = 0L;
1179 gboolean _tmp27_;
1180 _tmp27_ = valadoc_highlighter_code_scanner_has_template_literal_prefix (self, &_tmp26_);
1181 skip = _tmp26_;
1182 _tmp23_ = _tmp27_;
1183 } else {
1184 _tmp23_ = FALSE;
1185 }
1186 _tmp13_ = _tmp23_;
1187 }
1188 if (_tmp13_) {
1189 const gchar* _tmp28_;
1190 const gchar* _tmp29_;
1191 const gchar* sub_start = NULL;
1192 const gchar* _tmp30_;
1193 const gchar* _tmp31_;
1194 const gchar* _tmp32_;
1195 const gchar* _tmp33_;
1196 const gchar* _tmp34_;
1197 const gchar* _tmp35_;
1198 _tmp28_ = start;
1199 _tmp29_ = self->priv->pos;
1200 valadoc_highlighter_code_scanner_queue_token (self, _tmp28_, _tmp29_, VALADOC_HIGHLIGHTER_CODE_TOKEN_TYPE_LITERAL);
1201 _tmp30_ = self->priv->pos;
1202 sub_start = _tmp30_;
1203 _tmp31_ = self->priv->pos;
1204 _tmp32_ = string_offset (_tmp31_, skip);
1205 self->priv->pos = _tmp32_;
1206 _tmp33_ = sub_start;
1207 _tmp34_ = self->priv->pos;
1208 valadoc_highlighter_code_scanner_queue_token (self, _tmp33_, _tmp34_, VALADOC_HIGHLIGHTER_CODE_TOKEN_TYPE_ESCAPE);
1209 _tmp35_ = self->priv->pos;
1210 start = _tmp35_;
1211 } else {
1212 const gchar* _tmp36_;
1213 const gchar* _tmp37_;
1214 _tmp36_ = self->priv->pos;
1215 _tmp37_ = string_offset (_tmp36_, (glong) 1);
1216 self->priv->pos = _tmp37_;
1217 }
1218 }
1219 _tmp38_ = self->priv->pos;
1220 if (string_get (_tmp38_, (glong) 0) != '\0') {
1221 const gchar* _tmp39_;
1222 gint _tmp40_;
1223 gint _tmp41_;
1224 const gchar* _tmp42_;
1225 _tmp39_ = self->priv->pos;
1226 _tmp40_ = strlen (end_chars);
1227 _tmp41_ = _tmp40_;
1228 _tmp42_ = string_offset (_tmp39_, (glong) _tmp41_);
1229 self->priv->pos = _tmp42_;
1230 }
1231 _tmp43_ = start;
1232 _tmp44_ = self->priv->pos;
1233 valadoc_highlighter_code_scanner_queue_token (self, _tmp43_, _tmp44_, VALADOC_HIGHLIGHTER_CODE_TOKEN_TYPE_LITERAL);
1234 }
1235
1236 static gboolean
valadoc_highlighter_code_scanner_has_template_literal_prefix(ValadocHighlighterCodeScanner * self,glong * skip)1237 valadoc_highlighter_code_scanner_has_template_literal_prefix (ValadocHighlighterCodeScanner* self,
1238 glong* skip)
1239 {
1240 glong _vala_skip = 0L;
1241 const gchar* _tmp0_;
1242 const gchar* _tmp3_;
1243 gboolean result = FALSE;
1244 g_return_val_if_fail (self != NULL, FALSE);
1245 _tmp0_ = self->priv->pos;
1246 if (valadoc_highlighter_code_scanner_isidchar (self, string_get (_tmp0_, (glong) 1))) {
1247 _vala_skip = (glong) 1;
1248 while (TRUE) {
1249 const gchar* _tmp1_;
1250 glong _tmp2_;
1251 _tmp1_ = self->priv->pos;
1252 if (!valadoc_highlighter_code_scanner_isidchar (self, string_get (_tmp1_, _vala_skip))) {
1253 break;
1254 }
1255 _tmp2_ = _vala_skip;
1256 _vala_skip = _tmp2_ + 1;
1257 }
1258 result = TRUE;
1259 if (skip) {
1260 *skip = _vala_skip;
1261 }
1262 return result;
1263 }
1264 _tmp3_ = self->priv->pos;
1265 if (string_get (_tmp3_, (glong) 1) == '(') {
1266 gint level = 0;
1267 level = 1;
1268 _vala_skip = (glong) 2;
1269 while (TRUE) {
1270 const gchar* _tmp4_;
1271 glong _tmp7_;
1272 if (!(level > 0)) {
1273 break;
1274 }
1275 _tmp4_ = self->priv->pos;
1276 switch (string_get (_tmp4_, _vala_skip)) {
1277 case '(':
1278 {
1279 gint _tmp5_;
1280 _tmp5_ = level;
1281 level = _tmp5_ + 1;
1282 break;
1283 }
1284 case ')':
1285 {
1286 gint _tmp6_;
1287 _tmp6_ = level;
1288 level = _tmp6_ - 1;
1289 break;
1290 }
1291 case '\0':
1292 {
1293 _vala_skip = (glong) 0;
1294 result = FALSE;
1295 if (skip) {
1296 *skip = _vala_skip;
1297 }
1298 return result;
1299 }
1300 default:
1301 break;
1302 }
1303 _tmp7_ = _vala_skip;
1304 _vala_skip = _tmp7_ + 1;
1305 }
1306 result = TRUE;
1307 if (skip) {
1308 *skip = _vala_skip;
1309 }
1310 return result;
1311 }
1312 _vala_skip = (glong) 0;
1313 result = FALSE;
1314 if (skip) {
1315 *skip = _vala_skip;
1316 }
1317 return result;
1318 }
1319
1320 static gboolean
valadoc_highlighter_code_scanner_has_escape_prefix(ValadocHighlighterCodeScanner * self,glong * skip)1321 valadoc_highlighter_code_scanner_has_escape_prefix (ValadocHighlighterCodeScanner* self,
1322 glong* skip)
1323 {
1324 glong _vala_skip = 0L;
1325 const gchar* _tmp0_;
1326 gboolean result = FALSE;
1327 g_return_val_if_fail (self != NULL, FALSE);
1328 _tmp0_ = self->priv->pos;
1329 switch (string_get (_tmp0_, (glong) 1)) {
1330 case 'a':
1331 case 'b':
1332 case 'f':
1333 case 'n':
1334 case 'r':
1335 case 't':
1336 case 'v':
1337 case '\\':
1338 case '\'':
1339 case '\"':
1340 case '?':
1341 {
1342 _vala_skip = (glong) 2;
1343 result = TRUE;
1344 if (skip) {
1345 *skip = _vala_skip;
1346 }
1347 return result;
1348 }
1349 case 'x':
1350 {
1351 const gchar* _tmp1_;
1352 _tmp1_ = self->priv->pos;
1353 if (g_ascii_isxdigit (string_get (_tmp1_, (glong) 2))) {
1354 glong _tmp6_;
1355 {
1356 gboolean _tmp2_ = FALSE;
1357 _vala_skip = (glong) 2;
1358 _tmp2_ = TRUE;
1359 while (TRUE) {
1360 const gchar* _tmp4_;
1361 glong _tmp5_;
1362 if (!_tmp2_) {
1363 glong _tmp3_;
1364 _tmp3_ = _vala_skip;
1365 _vala_skip = _tmp3_ + 1;
1366 }
1367 _tmp2_ = FALSE;
1368 _tmp4_ = self->priv->pos;
1369 if (!g_ascii_isxdigit (string_get (_tmp4_, _vala_skip))) {
1370 break;
1371 }
1372 _tmp5_ = _vala_skip;
1373 _vala_skip = _tmp5_ + 1;
1374 }
1375 }
1376 _tmp6_ = _vala_skip;
1377 _vala_skip = _tmp6_ + 1;
1378 result = TRUE;
1379 if (skip) {
1380 *skip = _vala_skip;
1381 }
1382 return result;
1383 }
1384 _vala_skip = (glong) 0;
1385 result = FALSE;
1386 if (skip) {
1387 *skip = _vala_skip;
1388 }
1389 return result;
1390 }
1391 default:
1392 {
1393 const gchar* _tmp7_;
1394 _tmp7_ = self->priv->pos;
1395 if (g_ascii_isdigit (string_get (_tmp7_, (glong) 1))) {
1396 const gchar* _tmp8_;
1397 _vala_skip = (glong) 2;
1398 _tmp8_ = self->priv->pos;
1399 if (g_ascii_isdigit (string_get (_tmp8_, (glong) 2))) {
1400 glong _tmp9_;
1401 const gchar* _tmp10_;
1402 _tmp9_ = _vala_skip;
1403 _vala_skip = _tmp9_ + 1;
1404 _tmp10_ = self->priv->pos;
1405 if (g_ascii_isdigit (string_get (_tmp10_, (glong) 3))) {
1406 glong _tmp11_;
1407 _tmp11_ = _vala_skip;
1408 _vala_skip = _tmp11_ + 1;
1409 }
1410 }
1411 result = TRUE;
1412 if (skip) {
1413 *skip = _vala_skip;
1414 }
1415 return result;
1416 }
1417 _vala_skip = (glong) 0;
1418 result = FALSE;
1419 if (skip) {
1420 *skip = _vala_skip;
1421 }
1422 return result;
1423 }
1424 }
1425 if (skip) {
1426 *skip = _vala_skip;
1427 }
1428 }
1429
1430 static gint
string_index_of_char(const gchar * self,gunichar c,gint start_index)1431 string_index_of_char (const gchar* self,
1432 gunichar c,
1433 gint start_index)
1434 {
1435 gchar* _result_ = NULL;
1436 gchar* _tmp0_;
1437 gchar* _tmp1_;
1438 gint result = 0;
1439 g_return_val_if_fail (self != NULL, 0);
1440 _tmp0_ = g_utf8_strchr (((gchar*) self) + start_index, (gssize) -1, c);
1441 _result_ = _tmp0_;
1442 _tmp1_ = _result_;
1443 if (_tmp1_ != NULL) {
1444 gchar* _tmp2_;
1445 _tmp2_ = _result_;
1446 result = (gint) (_tmp2_ - ((gchar*) self));
1447 return result;
1448 } else {
1449 result = -1;
1450 return result;
1451 }
1452 }
1453
1454 static gboolean
valadoc_highlighter_code_scanner_has_printf_format_prefix(ValadocHighlighterCodeScanner * self,glong * skip)1455 valadoc_highlighter_code_scanner_has_printf_format_prefix (ValadocHighlighterCodeScanner* self,
1456 glong* skip)
1457 {
1458 glong _vala_skip = 0L;
1459 const gchar* pos = NULL;
1460 const gchar* _tmp0_;
1461 const gchar* start = NULL;
1462 const gchar* _tmp1_;
1463 const gchar* _tmp2_;
1464 const gchar* _tmp3_;
1465 const gchar* _tmp4_;
1466 gboolean _tmp13_ = FALSE;
1467 const gchar* _tmp14_;
1468 const gchar* _tmp21_;
1469 const gchar* _tmp34_;
1470 const gchar* _tmp37_;
1471 const gchar* _tmp38_;
1472 gboolean result = FALSE;
1473 g_return_val_if_fail (self != NULL, FALSE);
1474 _tmp0_ = self->priv->pos;
1475 pos = _tmp0_;
1476 _tmp1_ = pos;
1477 start = _tmp1_;
1478 _tmp2_ = pos;
1479 _tmp3_ = string_offset (_tmp2_, (glong) 1);
1480 pos = _tmp3_;
1481 _tmp4_ = pos;
1482 if (string_get (_tmp4_, (glong) 0) == '%') {
1483 const gchar* _tmp5_;
1484 const gchar* _tmp6_;
1485 _tmp5_ = pos;
1486 _tmp6_ = string_offset (_tmp5_, (glong) 1);
1487 pos = _tmp6_;
1488 _vala_skip = (glong) 2;
1489 result = TRUE;
1490 if (skip) {
1491 *skip = _vala_skip;
1492 }
1493 return result;
1494 }
1495 while (TRUE) {
1496 const gchar* _tmp7_;
1497 const gchar* _tmp8_;
1498 const gchar* _tmp9_;
1499 _tmp7_ = pos;
1500 if (!(string_index_of_char ("#0+- ", (gunichar) string_get (_tmp7_, (glong) 0), 0) > 0)) {
1501 break;
1502 }
1503 _tmp8_ = pos;
1504 _tmp9_ = string_offset (_tmp8_, (glong) 1);
1505 pos = _tmp9_;
1506 }
1507 while (TRUE) {
1508 const gchar* _tmp10_;
1509 const gchar* _tmp11_;
1510 const gchar* _tmp12_;
1511 _tmp10_ = pos;
1512 if (!g_ascii_isdigit (string_get (_tmp10_, (glong) 0))) {
1513 break;
1514 }
1515 _tmp11_ = pos;
1516 _tmp12_ = string_offset (_tmp11_, (glong) 1);
1517 pos = _tmp12_;
1518 }
1519 _tmp14_ = pos;
1520 if (string_get (_tmp14_, (glong) 0) == '.') {
1521 const gchar* _tmp15_;
1522 _tmp15_ = pos;
1523 _tmp13_ = g_ascii_isdigit (string_get (_tmp15_, (glong) 1));
1524 } else {
1525 _tmp13_ = FALSE;
1526 }
1527 if (_tmp13_) {
1528 const gchar* _tmp16_;
1529 const gchar* _tmp17_;
1530 _tmp16_ = pos;
1531 _tmp17_ = string_offset (_tmp16_, (glong) 2);
1532 pos = _tmp17_;
1533 while (TRUE) {
1534 const gchar* _tmp18_;
1535 const gchar* _tmp19_;
1536 const gchar* _tmp20_;
1537 _tmp18_ = pos;
1538 if (!g_ascii_isdigit (string_get (_tmp18_, (glong) 0))) {
1539 break;
1540 }
1541 _tmp19_ = pos;
1542 _tmp20_ = string_offset (_tmp19_, (glong) 1);
1543 pos = _tmp20_;
1544 }
1545 }
1546 _tmp21_ = pos;
1547 switch (string_get (_tmp21_, (glong) 0)) {
1548 case 'h':
1549 {
1550 const gchar* _tmp22_;
1551 const gchar* _tmp23_;
1552 const gchar* _tmp24_;
1553 _tmp22_ = pos;
1554 _tmp23_ = string_offset (_tmp22_, (glong) 1);
1555 pos = _tmp23_;
1556 _tmp24_ = pos;
1557 if (string_get (_tmp24_, (glong) 0) == 'h') {
1558 const gchar* _tmp25_;
1559 const gchar* _tmp26_;
1560 _tmp25_ = pos;
1561 _tmp26_ = string_offset (_tmp25_, (glong) 1);
1562 pos = _tmp26_;
1563 }
1564 break;
1565 }
1566 case 'l':
1567 {
1568 const gchar* _tmp27_;
1569 const gchar* _tmp28_;
1570 const gchar* _tmp29_;
1571 _tmp27_ = pos;
1572 _tmp28_ = string_offset (_tmp27_, (glong) 1);
1573 pos = _tmp28_;
1574 _tmp29_ = pos;
1575 if (string_get (_tmp29_, (glong) 0) == 'l') {
1576 const gchar* _tmp30_;
1577 const gchar* _tmp31_;
1578 _tmp30_ = pos;
1579 _tmp31_ = string_offset (_tmp30_, (glong) 1);
1580 pos = _tmp31_;
1581 }
1582 break;
1583 }
1584 case 'j':
1585 case 'z':
1586 case 't':
1587 case 'L':
1588 {
1589 const gchar* _tmp32_;
1590 const gchar* _tmp33_;
1591 _tmp32_ = pos;
1592 _tmp33_ = string_offset (_tmp32_, (glong) 1);
1593 pos = _tmp33_;
1594 break;
1595 }
1596 default:
1597 break;
1598 }
1599 _tmp34_ = pos;
1600 switch (string_get (_tmp34_, (glong) 0)) {
1601 case 'd':
1602 case 'i':
1603 case 'u':
1604 case 'o':
1605 case 'x':
1606 case 'X':
1607 case 'f':
1608 case 'F':
1609 case 'e':
1610 case 'E':
1611 case 'g':
1612 case 'G':
1613 case 'a':
1614 case 'A':
1615 case 'c':
1616 case 's':
1617 case 'p':
1618 case 'n':
1619 {
1620 const gchar* _tmp35_;
1621 const gchar* _tmp36_;
1622 _tmp35_ = pos;
1623 _tmp36_ = string_offset (_tmp35_, (glong) 1);
1624 pos = _tmp36_;
1625 break;
1626 }
1627 default:
1628 {
1629 _vala_skip = (glong) 0;
1630 result = FALSE;
1631 if (skip) {
1632 *skip = _vala_skip;
1633 }
1634 return result;
1635 }
1636 }
1637 _tmp37_ = start;
1638 _tmp38_ = pos;
1639 _vala_skip = string_pointer_to_offset (_tmp37_, _tmp38_);
1640 result = TRUE;
1641 if (skip) {
1642 *skip = _vala_skip;
1643 }
1644 return result;
1645 }
1646
1647 static void
valadoc_highlighter_code_scanner_queue_numeric_literal(ValadocHighlighterCodeScanner * self)1648 valadoc_highlighter_code_scanner_queue_numeric_literal (ValadocHighlighterCodeScanner* self)
1649 {
1650 ValadocHighlighterCodeScannerNumericType numeric_type = 0;
1651 const gchar* start = NULL;
1652 const gchar* _tmp0_;
1653 gboolean _tmp1_ = FALSE;
1654 gboolean _tmp2_ = FALSE;
1655 const gchar* _tmp3_;
1656 gboolean _tmp14_ = FALSE;
1657 const gchar* _tmp15_;
1658 gboolean _tmp22_ = FALSE;
1659 const gchar* _tmp23_;
1660 const gchar* _tmp35_;
1661 const gchar* _tmp59_;
1662 ValadocHighlighterCodeTokenType _tmp60_ = 0;
1663 ValadocHighlighterCodeScannerNumericType _tmp61_;
1664 const gchar* _tmp62_;
1665 const gchar* _tmp63_;
1666 g_return_if_fail (self != NULL);
1667 numeric_type = VALADOC_HIGHLIGHTER_CODE_SCANNER_NUMERIC_TYPE_INTEGER;
1668 _tmp0_ = self->priv->pos;
1669 start = _tmp0_;
1670 _tmp3_ = self->priv->pos;
1671 if (string_get (_tmp3_, (glong) 0) == '0') {
1672 const gchar* _tmp4_;
1673 _tmp4_ = self->priv->pos;
1674 _tmp2_ = string_get (_tmp4_, (glong) 1) == 'x';
1675 } else {
1676 _tmp2_ = FALSE;
1677 }
1678 if (_tmp2_) {
1679 const gchar* _tmp5_;
1680 _tmp5_ = self->priv->pos;
1681 _tmp1_ = g_ascii_isxdigit (string_get (_tmp5_, (glong) 2));
1682 } else {
1683 _tmp1_ = FALSE;
1684 }
1685 if (_tmp1_) {
1686 const gchar* _tmp6_;
1687 const gchar* _tmp7_;
1688 _tmp6_ = self->priv->pos;
1689 _tmp7_ = string_offset (_tmp6_, (glong) 2);
1690 self->priv->pos = _tmp7_;
1691 while (TRUE) {
1692 const gchar* _tmp8_;
1693 const gchar* _tmp9_;
1694 const gchar* _tmp10_;
1695 _tmp8_ = self->priv->pos;
1696 if (!g_ascii_isxdigit (string_get (_tmp8_, (glong) 0))) {
1697 break;
1698 }
1699 _tmp9_ = self->priv->pos;
1700 _tmp10_ = string_offset (_tmp9_, (glong) 1);
1701 self->priv->pos = _tmp10_;
1702 }
1703 } else {
1704 while (TRUE) {
1705 const gchar* _tmp11_;
1706 const gchar* _tmp12_;
1707 const gchar* _tmp13_;
1708 _tmp11_ = self->priv->pos;
1709 if (!g_ascii_isdigit (string_get (_tmp11_, (glong) 0))) {
1710 break;
1711 }
1712 _tmp12_ = self->priv->pos;
1713 _tmp13_ = string_offset (_tmp12_, (glong) 1);
1714 self->priv->pos = _tmp13_;
1715 }
1716 }
1717 _tmp15_ = self->priv->pos;
1718 if (string_get (_tmp15_, (glong) 0) == '.') {
1719 const gchar* _tmp16_;
1720 _tmp16_ = self->priv->pos;
1721 _tmp14_ = g_ascii_isdigit (string_get (_tmp16_, (glong) 1));
1722 } else {
1723 _tmp14_ = FALSE;
1724 }
1725 if (_tmp14_) {
1726 const gchar* _tmp17_;
1727 const gchar* _tmp18_;
1728 numeric_type = VALADOC_HIGHLIGHTER_CODE_SCANNER_NUMERIC_TYPE_REAL;
1729 _tmp17_ = self->priv->pos;
1730 _tmp18_ = string_offset (_tmp17_, (glong) 1);
1731 self->priv->pos = _tmp18_;
1732 while (TRUE) {
1733 const gchar* _tmp19_;
1734 const gchar* _tmp20_;
1735 const gchar* _tmp21_;
1736 _tmp19_ = self->priv->pos;
1737 if (!g_ascii_isdigit (string_get (_tmp19_, (glong) 0))) {
1738 break;
1739 }
1740 _tmp20_ = self->priv->pos;
1741 _tmp21_ = string_offset (_tmp20_, (glong) 1);
1742 self->priv->pos = _tmp21_;
1743 }
1744 }
1745 _tmp23_ = self->priv->pos;
1746 if (string_get (_tmp23_, (glong) 0) == 'e') {
1747 _tmp22_ = TRUE;
1748 } else {
1749 const gchar* _tmp24_;
1750 _tmp24_ = self->priv->pos;
1751 _tmp22_ = string_get (_tmp24_, (glong) 0) == 'E';
1752 }
1753 if (_tmp22_) {
1754 const gchar* _tmp25_;
1755 const gchar* _tmp26_;
1756 gboolean _tmp27_ = FALSE;
1757 const gchar* _tmp28_;
1758 numeric_type = VALADOC_HIGHLIGHTER_CODE_SCANNER_NUMERIC_TYPE_REAL;
1759 _tmp25_ = self->priv->pos;
1760 _tmp26_ = string_offset (_tmp25_, (glong) 1);
1761 self->priv->pos = _tmp26_;
1762 _tmp28_ = self->priv->pos;
1763 if (string_get (_tmp28_, (glong) 0) == '+') {
1764 _tmp27_ = TRUE;
1765 } else {
1766 const gchar* _tmp29_;
1767 _tmp29_ = self->priv->pos;
1768 _tmp27_ = string_get (_tmp29_, (glong) 0) == '-';
1769 }
1770 if (_tmp27_) {
1771 const gchar* _tmp30_;
1772 const gchar* _tmp31_;
1773 _tmp30_ = self->priv->pos;
1774 _tmp31_ = string_offset (_tmp30_, (glong) 1);
1775 self->priv->pos = _tmp31_;
1776 }
1777 while (TRUE) {
1778 const gchar* _tmp32_;
1779 const gchar* _tmp33_;
1780 const gchar* _tmp34_;
1781 _tmp32_ = self->priv->pos;
1782 if (!g_ascii_isdigit (string_get (_tmp32_, (glong) 0))) {
1783 break;
1784 }
1785 _tmp33_ = self->priv->pos;
1786 _tmp34_ = string_offset (_tmp33_, (glong) 1);
1787 self->priv->pos = _tmp34_;
1788 }
1789 }
1790 _tmp35_ = self->priv->pos;
1791 switch (string_get (_tmp35_, (glong) 0)) {
1792 case 'l':
1793 case 'L':
1794 {
1795 ValadocHighlighterCodeScannerNumericType _tmp36_;
1796 _tmp36_ = numeric_type;
1797 if (_tmp36_ == VALADOC_HIGHLIGHTER_CODE_SCANNER_NUMERIC_TYPE_INTEGER) {
1798 const gchar* _tmp37_;
1799 const gchar* _tmp38_;
1800 gboolean _tmp39_ = FALSE;
1801 const gchar* _tmp40_;
1802 _tmp37_ = self->priv->pos;
1803 _tmp38_ = string_offset (_tmp37_, (glong) 1);
1804 self->priv->pos = _tmp38_;
1805 _tmp40_ = self->priv->pos;
1806 if (string_get (_tmp40_, (glong) 0) == 'l') {
1807 _tmp39_ = TRUE;
1808 } else {
1809 const gchar* _tmp41_;
1810 _tmp41_ = self->priv->pos;
1811 _tmp39_ = string_get (_tmp41_, (glong) 0) == 'L';
1812 }
1813 if (_tmp39_) {
1814 const gchar* _tmp42_;
1815 const gchar* _tmp43_;
1816 _tmp42_ = self->priv->pos;
1817 _tmp43_ = string_offset (_tmp42_, (glong) 1);
1818 self->priv->pos = _tmp43_;
1819 }
1820 }
1821 break;
1822 }
1823 case 'u':
1824 case 'U':
1825 {
1826 ValadocHighlighterCodeScannerNumericType _tmp44_;
1827 _tmp44_ = numeric_type;
1828 if (_tmp44_ == VALADOC_HIGHLIGHTER_CODE_SCANNER_NUMERIC_TYPE_INTEGER) {
1829 const gchar* _tmp45_;
1830 const gchar* _tmp46_;
1831 gboolean _tmp47_ = FALSE;
1832 const gchar* _tmp48_;
1833 _tmp45_ = self->priv->pos;
1834 _tmp46_ = string_offset (_tmp45_, (glong) 1);
1835 self->priv->pos = _tmp46_;
1836 _tmp48_ = self->priv->pos;
1837 if (string_get (_tmp48_, (glong) 0) == 'l') {
1838 _tmp47_ = TRUE;
1839 } else {
1840 const gchar* _tmp49_;
1841 _tmp49_ = self->priv->pos;
1842 _tmp47_ = string_get (_tmp49_, (glong) 0) == 'L';
1843 }
1844 if (_tmp47_) {
1845 const gchar* _tmp50_;
1846 const gchar* _tmp51_;
1847 gboolean _tmp52_ = FALSE;
1848 const gchar* _tmp53_;
1849 _tmp50_ = self->priv->pos;
1850 _tmp51_ = string_offset (_tmp50_, (glong) 1);
1851 self->priv->pos = _tmp51_;
1852 _tmp53_ = self->priv->pos;
1853 if (string_get (_tmp53_, (glong) 0) == 'l') {
1854 _tmp52_ = TRUE;
1855 } else {
1856 const gchar* _tmp54_;
1857 _tmp54_ = self->priv->pos;
1858 _tmp52_ = string_get (_tmp54_, (glong) 0) == 'L';
1859 }
1860 if (_tmp52_) {
1861 const gchar* _tmp55_;
1862 const gchar* _tmp56_;
1863 _tmp55_ = self->priv->pos;
1864 _tmp56_ = string_offset (_tmp55_, (glong) 1);
1865 self->priv->pos = _tmp56_;
1866 }
1867 }
1868 }
1869 break;
1870 }
1871 case 'f':
1872 case 'F':
1873 case 'd':
1874 case 'D':
1875 {
1876 const gchar* _tmp57_;
1877 const gchar* _tmp58_;
1878 numeric_type = VALADOC_HIGHLIGHTER_CODE_SCANNER_NUMERIC_TYPE_REAL;
1879 _tmp57_ = self->priv->pos;
1880 _tmp58_ = string_offset (_tmp57_, (glong) 1);
1881 self->priv->pos = _tmp58_;
1882 break;
1883 }
1884 default:
1885 break;
1886 }
1887 _tmp59_ = self->priv->pos;
1888 if (g_ascii_isalnum (string_get (_tmp59_, (glong) 0))) {
1889 numeric_type = VALADOC_HIGHLIGHTER_CODE_SCANNER_NUMERIC_TYPE_NONE;
1890 }
1891 _tmp61_ = numeric_type;
1892 if (_tmp61_ != VALADOC_HIGHLIGHTER_CODE_SCANNER_NUMERIC_TYPE_NONE) {
1893 _tmp60_ = VALADOC_HIGHLIGHTER_CODE_TOKEN_TYPE_LITERAL;
1894 } else {
1895 _tmp60_ = VALADOC_HIGHLIGHTER_CODE_TOKEN_TYPE_PLAIN;
1896 }
1897 _tmp62_ = start;
1898 _tmp63_ = self->priv->pos;
1899 valadoc_highlighter_code_scanner_queue_token (self, _tmp62_, _tmp63_, _tmp60_);
1900 }
1901
1902 static ValadocHighlighterCodeToken*
valadoc_highlighter_code_scanner_dispatch(ValadocHighlighterCodeScanner * self,const gchar * start,const gchar * end)1903 valadoc_highlighter_code_scanner_dispatch (ValadocHighlighterCodeScanner* self,
1904 const gchar* start,
1905 const gchar* end)
1906 {
1907 GQueue* _tmp0_;
1908 glong length = 0L;
1909 gchar* content = NULL;
1910 gchar* _tmp3_;
1911 const gchar* _tmp4_;
1912 ValadocHighlighterCodeToken* _tmp5_;
1913 ValadocHighlighterCodeToken* result = NULL;
1914 g_return_val_if_fail (self != NULL, NULL);
1915 g_return_val_if_fail (start != NULL, NULL);
1916 g_return_val_if_fail (end != NULL, NULL);
1917 _tmp0_ = self->priv->token_queue;
1918 _vala_assert (g_queue_is_empty (_tmp0_) == FALSE, "token_queue.is_empty () == false");
1919 if (((gchar*) start) == ((gchar*) end)) {
1920 GQueue* _tmp1_;
1921 gpointer _tmp2_;
1922 _tmp1_ = self->priv->token_queue;
1923 _tmp2_ = g_queue_pop_head (_tmp1_);
1924 result = (ValadocHighlighterCodeToken*) _tmp2_;
1925 return result;
1926 }
1927 length = string_pointer_to_offset (start, end);
1928 _tmp3_ = string_substring (start, (glong) 0, length);
1929 content = _tmp3_;
1930 _tmp4_ = content;
1931 _tmp5_ = valadoc_highlighter_code_token_new (VALADOC_HIGHLIGHTER_CODE_TOKEN_TYPE_PLAIN, _tmp4_);
1932 result = _tmp5_;
1933 _g_free0 (content);
1934 return result;
1935 }
1936
1937 static void
valadoc_highlighter_code_scanner_queue_token(ValadocHighlighterCodeScanner * self,const gchar * start,const gchar * end,ValadocHighlighterCodeTokenType token_type)1938 valadoc_highlighter_code_scanner_queue_token (ValadocHighlighterCodeScanner* self,
1939 const gchar* start,
1940 const gchar* end,
1941 ValadocHighlighterCodeTokenType token_type)
1942 {
1943 glong length = 0L;
1944 gchar* content = NULL;
1945 gchar* _tmp0_;
1946 GQueue* _tmp1_;
1947 ValadocHighlighterCodeToken* _tmp2_;
1948 g_return_if_fail (self != NULL);
1949 g_return_if_fail (start != NULL);
1950 g_return_if_fail (end != NULL);
1951 length = string_pointer_to_offset (start, end);
1952 _tmp0_ = string_substring (start, (glong) 0, length);
1953 content = _tmp0_;
1954 _tmp1_ = self->priv->token_queue;
1955 _tmp2_ = valadoc_highlighter_code_token_new (token_type, content);
1956 g_queue_push_tail (_tmp1_, _tmp2_);
1957 _g_free0 (content);
1958 }
1959
1960 static inline gboolean
valadoc_highlighter_code_scanner_isidchar(ValadocHighlighterCodeScanner * self,gchar c)1961 valadoc_highlighter_code_scanner_isidchar (ValadocHighlighterCodeScanner* self,
1962 gchar c)
1963 {
1964 gboolean _tmp0_ = FALSE;
1965 gboolean result = FALSE;
1966 g_return_val_if_fail (self != NULL, FALSE);
1967 if (g_ascii_isalnum (c)) {
1968 _tmp0_ = TRUE;
1969 } else {
1970 _tmp0_ = c == '_';
1971 }
1972 result = _tmp0_;
1973 return result;
1974 }
1975
1976 static inline gboolean
valadoc_highlighter_code_scanner_isidstartchar(ValadocHighlighterCodeScanner * self,gchar c)1977 valadoc_highlighter_code_scanner_isidstartchar (ValadocHighlighterCodeScanner* self,
1978 gchar c)
1979 {
1980 gboolean _tmp0_ = FALSE;
1981 gboolean _tmp1_ = FALSE;
1982 gboolean result = FALSE;
1983 g_return_val_if_fail (self != NULL, FALSE);
1984 if (g_ascii_isalnum (c)) {
1985 _tmp1_ = TRUE;
1986 } else {
1987 _tmp1_ = c == '_';
1988 }
1989 if (_tmp1_) {
1990 _tmp0_ = TRUE;
1991 } else {
1992 gboolean _tmp2_ = FALSE;
1993 if (c == '@') {
1994 _tmp2_ = self->priv->enable_keyword_escape;
1995 } else {
1996 _tmp2_ = FALSE;
1997 }
1998 _tmp0_ = _tmp2_;
1999 }
2000 result = _tmp0_;
2001 return result;
2002 }
2003
2004 static void
valadoc_highlighter_code_scanner_class_init(ValadocHighlighterCodeScannerClass * klass,gpointer klass_data)2005 valadoc_highlighter_code_scanner_class_init (ValadocHighlighterCodeScannerClass * klass,
2006 gpointer klass_data)
2007 {
2008 valadoc_highlighter_code_scanner_parent_class = g_type_class_peek_parent (klass);
2009 g_type_class_adjust_private_offset (klass, &ValadocHighlighterCodeScanner_private_offset);
2010 G_OBJECT_CLASS (klass)->finalize = valadoc_highlighter_code_scanner_finalize;
2011 }
2012
2013 static void
valadoc_highlighter_code_scanner_valadoc_highlighter_scanner_interface_init(ValadocHighlighterScannerIface * iface,gpointer iface_data)2014 valadoc_highlighter_code_scanner_valadoc_highlighter_scanner_interface_init (ValadocHighlighterScannerIface * iface,
2015 gpointer iface_data)
2016 {
2017 valadoc_highlighter_code_scanner_valadoc_highlighter_scanner_parent_iface = g_type_interface_peek_parent (iface);
2018 iface->next = (ValadocHighlighterCodeToken* (*) (ValadocHighlighterScanner*)) valadoc_highlighter_code_scanner_real_next;
2019 }
2020
2021 static void
valadoc_highlighter_code_scanner_instance_init(ValadocHighlighterCodeScanner * self,gpointer klass)2022 valadoc_highlighter_code_scanner_instance_init (ValadocHighlighterCodeScanner * self,
2023 gpointer klass)
2024 {
2025 GQueue* _tmp0_;
2026 self->priv = valadoc_highlighter_code_scanner_get_instance_private (self);
2027 _tmp0_ = g_queue_new ();
2028 self->priv->token_queue = _tmp0_;
2029 }
2030
2031 static void
valadoc_highlighter_code_scanner_finalize(GObject * obj)2032 valadoc_highlighter_code_scanner_finalize (GObject * obj)
2033 {
2034 ValadocHighlighterCodeScanner * self;
2035 self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALADOC_HIGHLIGHTER_TYPE_CODE_SCANNER, ValadocHighlighterCodeScanner);
2036 _vala_map_unref0 (self->priv->keywords);
2037 (self->priv->token_queue == NULL) ? NULL : (self->priv->token_queue = (_g_queue_free__valadoc_highlighter_code_token_unref0_ (self->priv->token_queue), NULL));
2038 G_OBJECT_CLASS (valadoc_highlighter_code_scanner_parent_class)->finalize (obj);
2039 }
2040
2041 /**
2042 * A cheap scanner used to highlight C and Vala source code.
2043 */
2044 static GType
valadoc_highlighter_code_scanner_get_type_once(void)2045 valadoc_highlighter_code_scanner_get_type_once (void)
2046 {
2047 static const GTypeInfo g_define_type_info = { sizeof (ValadocHighlighterCodeScannerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) valadoc_highlighter_code_scanner_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValadocHighlighterCodeScanner), 0, (GInstanceInitFunc) valadoc_highlighter_code_scanner_instance_init, NULL };
2048 static const GInterfaceInfo valadoc_highlighter_scanner_info = { (GInterfaceInitFunc) valadoc_highlighter_code_scanner_valadoc_highlighter_scanner_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
2049 GType valadoc_highlighter_code_scanner_type_id;
2050 valadoc_highlighter_code_scanner_type_id = g_type_register_static (G_TYPE_OBJECT, "ValadocHighlighterCodeScanner", &g_define_type_info, 0);
2051 g_type_add_interface_static (valadoc_highlighter_code_scanner_type_id, VALADOC_HIGHLIGHTER_TYPE_SCANNER, &valadoc_highlighter_scanner_info);
2052 ValadocHighlighterCodeScanner_private_offset = g_type_add_instance_private (valadoc_highlighter_code_scanner_type_id, sizeof (ValadocHighlighterCodeScannerPrivate));
2053 return valadoc_highlighter_code_scanner_type_id;
2054 }
2055
2056 GType
valadoc_highlighter_code_scanner_get_type(void)2057 valadoc_highlighter_code_scanner_get_type (void)
2058 {
2059 static volatile gsize valadoc_highlighter_code_scanner_type_id__volatile = 0;
2060 if (g_once_init_enter (&valadoc_highlighter_code_scanner_type_id__volatile)) {
2061 GType valadoc_highlighter_code_scanner_type_id;
2062 valadoc_highlighter_code_scanner_type_id = valadoc_highlighter_code_scanner_get_type_once ();
2063 g_once_init_leave (&valadoc_highlighter_code_scanner_type_id__volatile, valadoc_highlighter_code_scanner_type_id);
2064 }
2065 return valadoc_highlighter_code_scanner_type_id__volatile;
2066 }
2067
2068