File Coverage

tstr_cparse_rfc9557.c
Criterion Covered Total %
statement 187 325 57.5
branch 103 200 51.5
condition n/a
subroutine n/a
pod n/a
total 290 525 55.2


line stmt bran cond sub pod time code
1              
2             #line 1 "ragel/tstr_cparse_rfc9557.rl"
3             #include
4             #include
5             #include
6              
7             #include "tstr_parsed.h"
8             #include "tstr_token_parse.h"
9             #include "tstr_cparse.h"
10              
11              
12             #line 30 "ragel/tstr_cparse_rfc9557.rl"
13              
14              
15              
16             #line 17 "tstr_cparse_rfc9557.c"
17             static const int rfc9557_start = 1;
18             static const int rfc9557_first_final = 38;
19             static const int rfc9557_error = 0;
20              
21             static const int rfc9557_en_main = 1;
22              
23              
24             #line 33 "ragel/tstr_cparse_rfc9557.rl"
25              
26             tstr_parse_result_t tstr_cparse_rfc9557(const char* p,
27             size_t len,
28             tstr_parsed_t* parsed) {
29             int cs, v;
30             const char* pe = p + len;
31             const char* eof = pe;
32             const char* mark = NULL;
33             tstr_parse_result_t result = TSTR_PARSE_OK;
34              
35             (void)tstr_parsed_init(parsed);
36              
37            
38             #line 39 "tstr_cparse_rfc9557.c"
39             {
40 45           cs = rfc9557_start;
41             }
42              
43             #line 46 "ragel/tstr_cparse_rfc9557.rl"
44            
45             #line 46 "tstr_cparse_rfc9557.c"
46             {
47 45 50         if ( p == pe )
48 0           goto _test_eof;
49 45           switch ( cs )
50             {
51 45           case 1:
52 45 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
53 45           goto tr0;
54 0           goto st0;
55 0           st0:
56 0           cs = 0;
57 0           goto _out;
58 45           tr0:
59             #line 4 "ragel/tstr_common.rl"
60             { mark = p; }
61             goto st2;
62             st2:
63             if ( ++p == pe )
64             goto _test_eof2;
65             case 2:
66             #line 67 "tstr_cparse_rfc9557.c"
67 45 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
68 45           goto st3;
69 0           goto st0;
70 45           st3:
71 45 50         if ( ++p == pe )
72 0           goto _test_eof3;
73             case 3:
74 45 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
75 45           goto st4;
76 0           goto st0;
77 45           st4:
78 45 50         if ( ++p == pe )
79 0           goto _test_eof4;
80             case 4:
81 45 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
82 45           goto st5;
83 0           goto st0;
84 45           st5:
85 45 50         if ( ++p == pe )
86 0           goto _test_eof5;
87             case 5:
88 45 50         if ( (*p) == 45 )
89 45           goto tr5;
90 0           goto st0;
91 45           tr5:
92             #line 6 "ragel/tstr_common.rl"
93             {
94             if (!tstr_token_parse_year(mark, p - mark, &v)) {
95             result = TSTR_PARSE_ERR_YEAR;
96             {p++; cs = 6; goto _out;}
97             }
98             tstr_parsed_set_year4(parsed, v);
99             }
100             goto st6;
101             st6:
102             if ( ++p == pe )
103             goto _test_eof6;
104             case 6:
105             #line 106 "tstr_cparse_rfc9557.c"
106 45 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
107 45           goto tr6;
108 0           goto st0;
109 45           tr6:
110             #line 4 "ragel/tstr_common.rl"
111             { mark = p; }
112             goto st7;
113             st7:
114             if ( ++p == pe )
115             goto _test_eof7;
116             case 7:
117             #line 118 "tstr_cparse_rfc9557.c"
118 45 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
119 45           goto st8;
120 0           goto st0;
121 45           st8:
122 45 50         if ( ++p == pe )
123 0           goto _test_eof8;
124             case 8:
125 45 50         if ( (*p) == 45 )
126 45           goto tr8;
127 0           goto st0;
128 45           tr8:
129             #line 22 "ragel/tstr_common.rl"
130             {
131             if (!tstr_token_parse_month(mark, p - mark, &v)) {
132             result = TSTR_PARSE_ERR_MONTH;
133             {p++; cs = 9; goto _out;}
134             }
135             tstr_parsed_set_month(parsed, v);
136             }
137             goto st9;
138             st9:
139             if ( ++p == pe )
140             goto _test_eof9;
141             case 9:
142             #line 143 "tstr_cparse_rfc9557.c"
143 45 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
144 45           goto tr9;
145 0           goto st0;
146 45           tr9:
147             #line 4 "ragel/tstr_common.rl"
148             { mark = p; }
149             goto st10;
150             st10:
151             if ( ++p == pe )
152             goto _test_eof10;
153             case 10:
154             #line 155 "tstr_cparse_rfc9557.c"
155 45 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
156 45           goto st11;
157 0           goto st0;
158 45           st11:
159 45 50         if ( ++p == pe )
160 0           goto _test_eof11;
161             case 11:
162 45           switch( (*p) ) {
163 1           case 32: goto tr11;
164 43           case 84: goto tr11;
165 1           case 116: goto tr11;
166             }
167 0           goto st0;
168 45           tr11:
169             #line 30 "ragel/tstr_common.rl"
170             {
171             if (!tstr_token_parse_day(mark, p - mark, &v)) {
172             result = TSTR_PARSE_ERR_DAY;
173             {p++; cs = 12; goto _out;}
174             }
175             tstr_parsed_set_day(parsed, v);
176             }
177             goto st12;
178             st12:
179             if ( ++p == pe )
180             goto _test_eof12;
181             case 12:
182             #line 183 "tstr_cparse_rfc9557.c"
183 45 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
184 45           goto tr12;
185 0           goto st0;
186 45           tr12:
187             #line 4 "ragel/tstr_common.rl"
188             { mark = p; }
189             goto st13;
190             st13:
191             if ( ++p == pe )
192             goto _test_eof13;
193             case 13:
194             #line 195 "tstr_cparse_rfc9557.c"
195 45 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
196 45           goto st14;
197 0           goto st0;
198 45           st14:
199 45 50         if ( ++p == pe )
200 0           goto _test_eof14;
201             case 14:
202 45 50         if ( (*p) == 58 )
203 45           goto tr14;
204 0           goto st0;
205 45           tr14:
206             #line 46 "ragel/tstr_common.rl"
207             {
208             if (!tstr_token_parse_hour(mark, p - mark, &v)) {
209             result = TSTR_PARSE_ERR_HOUR;
210             {p++; cs = 15; goto _out;}
211             }
212             tstr_parsed_set_hour(parsed, v);
213             }
214             goto st15;
215             st15:
216             if ( ++p == pe )
217             goto _test_eof15;
218             case 15:
219             #line 220 "tstr_cparse_rfc9557.c"
220 45 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
221 45           goto tr15;
222 0           goto st0;
223 45           tr15:
224             #line 4 "ragel/tstr_common.rl"
225             { mark = p; }
226             goto st16;
227             st16:
228             if ( ++p == pe )
229             goto _test_eof16;
230             case 16:
231             #line 232 "tstr_cparse_rfc9557.c"
232 45 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
233 45           goto st17;
234 0           goto st0;
235 45           st17:
236 45 50         if ( ++p == pe )
237 0           goto _test_eof17;
238             case 17:
239 45 50         if ( (*p) == 58 )
240 45           goto tr17;
241 0           goto st0;
242 45           tr17:
243             #line 54 "ragel/tstr_common.rl"
244             {
245             if (!tstr_token_parse_minute(mark, p - mark, &v)) {
246             result = TSTR_PARSE_ERR_MINUTE;
247             {p++; cs = 18; goto _out;}
248             }
249             tstr_parsed_set_minute(parsed, v);
250             }
251             goto st18;
252             st18:
253             if ( ++p == pe )
254             goto _test_eof18;
255             case 18:
256             #line 257 "tstr_cparse_rfc9557.c"
257 45 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
258 45           goto tr18;
259 0           goto st0;
260 45           tr18:
261             #line 4 "ragel/tstr_common.rl"
262             { mark = p; }
263             goto st19;
264             st19:
265             if ( ++p == pe )
266             goto _test_eof19;
267             case 19:
268             #line 269 "tstr_cparse_rfc9557.c"
269 45 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
270 45           goto st20;
271 0           goto st0;
272 45           st20:
273 45 50         if ( ++p == pe )
274 0           goto _test_eof20;
275             case 20:
276 45           switch( (*p) ) {
277 10           case 43: goto tr20;
278 7           case 45: goto tr20;
279 11           case 46: goto tr21;
280 16           case 90: goto tr22;
281 1           case 122: goto tr22;
282             }
283 0           goto st0;
284 17           tr20:
285             #line 62 "ragel/tstr_common.rl"
286             {
287             if (!tstr_token_parse_second(mark, p - mark, &v)) {
288             result = TSTR_PARSE_ERR_SECOND;
289             {p++; cs = 21; goto _out;}
290             }
291             tstr_parsed_set_second(parsed, v);
292             }
293             #line 4 "ragel/tstr_common.rl"
294             { mark = p; }
295             goto st21;
296             tr31:
297             #line 70 "ragel/tstr_common.rl"
298             {
299             if (!tstr_token_parse_fraction(mark, p - mark, &v)) {
300             result = TSTR_PARSE_ERR_FRACTION;
301             {p++; cs = 21; goto _out;}
302             }
303             tstr_parsed_set_fraction(parsed, v);
304             }
305             #line 4 "ragel/tstr_common.rl"
306             { mark = p; }
307             goto st21;
308             st21:
309             if ( ++p == pe )
310             goto _test_eof21;
311             case 21:
312             #line 313 "tstr_cparse_rfc9557.c"
313 18 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
314 18           goto st22;
315 0           goto st0;
316 18           st22:
317 18 50         if ( ++p == pe )
318 0           goto _test_eof22;
319             case 22:
320 18 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
321 18           goto st23;
322 0           goto st0;
323 18           st23:
324 18 50         if ( ++p == pe )
325 0           goto _test_eof23;
326             case 23:
327 18 50         if ( (*p) == 58 )
328 18           goto st24;
329 0           goto st0;
330 18           st24:
331 18 50         if ( ++p == pe )
332 0           goto _test_eof24;
333             case 24:
334 18 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
335 18           goto st25;
336 0           goto st0;
337 18           st25:
338 18 50         if ( ++p == pe )
339 0           goto _test_eof25;
340             case 25:
341 18 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
342 18           goto st38;
343 0           goto st0;
344 18           st38:
345 18 100         if ( ++p == pe )
346 10           goto _test_eof38;
347             case 38:
348 8 50         if ( (*p) == 91 )
349 8           goto tr41;
350 0           goto st0;
351 8           tr41:
352             #line 78 "ragel/tstr_common.rl"
353             {
354             if (!tstr_token_parse_tz_offset(mark, p - mark, &v)) {
355             result = TSTR_PARSE_ERR_OFFSET;
356             {p++; cs = 26; goto _out;}
357             }
358             tstr_parsed_set_offset(parsed, v);
359             }
360             #line 4 "ragel/tstr_common.rl"
361             { mark = p; }
362             goto st26;
363             tr43:
364             #line 86 "ragel/tstr_common.rl"
365             {
366             tstr_parsed_set_tz_utc(parsed, mark, p - mark);
367             }
368             #line 4 "ragel/tstr_common.rl"
369             { mark = p; }
370             goto st26;
371             st26:
372             if ( ++p == pe )
373             goto _test_eof26;
374             case 26:
375             #line 376 "tstr_cparse_rfc9557.c"
376 28           switch( (*p) ) {
377 1           case 33: goto st27;
378 0           case 43: goto st27;
379 0           case 95: goto st27;
380             }
381 27 50         if ( (*p) < 65 ) {
382 0 0         if ( 45 <= (*p) && (*p) <= 57 )
    0          
383 0           goto st27;
384 27 100         } else if ( (*p) > 90 ) {
385 3 50         if ( 97 <= (*p) && (*p) <= 122 )
    50          
386 3           goto st27;
387             } else
388 24           goto st27;
389 0           goto st0;
390 367           st27:
391 367 50         if ( ++p == pe )
392 0           goto _test_eof27;
393             case 27:
394 367           switch( (*p) ) {
395 0           case 33: goto st27;
396 0           case 43: goto st27;
397 28           case 93: goto st39;
398 3           case 95: goto st27;
399             }
400 336 100         if ( (*p) < 65 ) {
401 32 50         if ( 45 <= (*p) && (*p) <= 57 )
    50          
402 32           goto st27;
403 304 100         } else if ( (*p) > 90 ) {
404 265 50         if ( 97 <= (*p) && (*p) <= 122 )
    50          
405 265           goto st27;
406             } else
407 39           goto st27;
408 0           goto st0;
409 28           st39:
410 28 100         if ( ++p == pe )
411 26           goto _test_eof39;
412             case 39:
413 2 50         if ( (*p) == 91 )
414 2           goto st26;
415 0           goto st0;
416 11           tr21:
417             #line 62 "ragel/tstr_common.rl"
418             {
419             if (!tstr_token_parse_second(mark, p - mark, &v)) {
420             result = TSTR_PARSE_ERR_SECOND;
421             {p++; cs = 28; goto _out;}
422             }
423             tstr_parsed_set_second(parsed, v);
424             }
425             goto st28;
426             st28:
427             if ( ++p == pe )
428             goto _test_eof28;
429             case 28:
430             #line 431 "tstr_cparse_rfc9557.c"
431 11 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
432 11           goto tr30;
433 0           goto st0;
434 11           tr30:
435             #line 4 "ragel/tstr_common.rl"
436             { mark = p; }
437             goto st29;
438             st29:
439             if ( ++p == pe )
440             goto _test_eof29;
441             case 29:
442             #line 443 "tstr_cparse_rfc9557.c"
443 11           switch( (*p) ) {
444 0           case 43: goto tr31;
445 0           case 45: goto tr31;
446 3           case 90: goto tr33;
447 0           case 122: goto tr33;
448             }
449 8 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
450 8           goto st30;
451 0           goto st0;
452 8           st30:
453 8 50         if ( ++p == pe )
454 0           goto _test_eof30;
455             case 30:
456 8           switch( (*p) ) {
457 0           case 43: goto tr31;
458 0           case 45: goto tr31;
459 0           case 90: goto tr33;
460 0           case 122: goto tr33;
461             }
462 8 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
463 8           goto st31;
464 0           goto st0;
465 8           st31:
466 8 50         if ( ++p == pe )
467 0           goto _test_eof31;
468             case 31:
469 8           switch( (*p) ) {
470 0           case 43: goto tr31;
471 0           case 45: goto tr31;
472 3           case 90: goto tr33;
473 0           case 122: goto tr33;
474             }
475 5 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
476 5           goto st32;
477 0           goto st0;
478 5           st32:
479 5 50         if ( ++p == pe )
480 0           goto _test_eof32;
481             case 32:
482 5           switch( (*p) ) {
483 0           case 43: goto tr31;
484 0           case 45: goto tr31;
485 0           case 90: goto tr33;
486 0           case 122: goto tr33;
487             }
488 5 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
489 5           goto st33;
490 0           goto st0;
491 5           st33:
492 5 50         if ( ++p == pe )
493 0           goto _test_eof33;
494             case 33:
495 5           switch( (*p) ) {
496 0           case 43: goto tr31;
497 0           case 45: goto tr31;
498 0           case 90: goto tr33;
499 0           case 122: goto tr33;
500             }
501 5 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
502 5           goto st34;
503 0           goto st0;
504 5           st34:
505 5 50         if ( ++p == pe )
506 0           goto _test_eof34;
507             case 34:
508 5           switch( (*p) ) {
509 0           case 43: goto tr31;
510 0           case 45: goto tr31;
511 1           case 90: goto tr33;
512 0           case 122: goto tr33;
513             }
514 4 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
515 4           goto st35;
516 0           goto st0;
517 4           st35:
518 4 50         if ( ++p == pe )
519 0           goto _test_eof35;
520             case 35:
521 4           switch( (*p) ) {
522 0           case 43: goto tr31;
523 0           case 45: goto tr31;
524 0           case 90: goto tr33;
525 0           case 122: goto tr33;
526             }
527 4 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
528 4           goto st36;
529 0           goto st0;
530 4           st36:
531 4 50         if ( ++p == pe )
532 0           goto _test_eof36;
533             case 36:
534 4           switch( (*p) ) {
535 0           case 43: goto tr31;
536 0           case 45: goto tr31;
537 0           case 90: goto tr33;
538 0           case 122: goto tr33;
539             }
540 4 50         if ( 48 <= (*p) && (*p) <= 57 )
    50          
541 4           goto st37;
542 0           goto st0;
543 4           st37:
544 4 50         if ( ++p == pe )
545 0           goto _test_eof37;
546             case 37:
547 4           switch( (*p) ) {
548 1           case 43: goto tr31;
549 0           case 45: goto tr31;
550 3           case 90: goto tr33;
551 0           case 122: goto tr33;
552             }
553 0           goto st0;
554 17           tr22:
555             #line 62 "ragel/tstr_common.rl"
556             {
557             if (!tstr_token_parse_second(mark, p - mark, &v)) {
558             result = TSTR_PARSE_ERR_SECOND;
559             {p++; cs = 40; goto _out;}
560             }
561             tstr_parsed_set_second(parsed, v);
562             }
563             #line 4 "ragel/tstr_common.rl"
564             { mark = p; }
565             goto st40;
566             tr33:
567             #line 70 "ragel/tstr_common.rl"
568             {
569             if (!tstr_token_parse_fraction(mark, p - mark, &v)) {
570             result = TSTR_PARSE_ERR_FRACTION;
571             {p++; cs = 40; goto _out;}
572             }
573             tstr_parsed_set_fraction(parsed, v);
574             }
575             #line 4 "ragel/tstr_common.rl"
576             { mark = p; }
577             goto st40;
578             st40:
579             if ( ++p == pe )
580             goto _test_eof40;
581             case 40:
582             #line 583 "tstr_cparse_rfc9557.c"
583 18 50         if ( (*p) == 91 )
584 18           goto tr43;
585 0           goto st0;
586             }
587 0           _test_eof2: cs = 2; goto _test_eof;
588 0           _test_eof3: cs = 3; goto _test_eof;
589 0           _test_eof4: cs = 4; goto _test_eof;
590 0           _test_eof5: cs = 5; goto _test_eof;
591 0           _test_eof6: cs = 6; goto _test_eof;
592 0           _test_eof7: cs = 7; goto _test_eof;
593 0           _test_eof8: cs = 8; goto _test_eof;
594 0           _test_eof9: cs = 9; goto _test_eof;
595 0           _test_eof10: cs = 10; goto _test_eof;
596 0           _test_eof11: cs = 11; goto _test_eof;
597 0           _test_eof12: cs = 12; goto _test_eof;
598 0           _test_eof13: cs = 13; goto _test_eof;
599 0           _test_eof14: cs = 14; goto _test_eof;
600 0           _test_eof15: cs = 15; goto _test_eof;
601 0           _test_eof16: cs = 16; goto _test_eof;
602 0           _test_eof17: cs = 17; goto _test_eof;
603 0           _test_eof18: cs = 18; goto _test_eof;
604 0           _test_eof19: cs = 19; goto _test_eof;
605 0           _test_eof20: cs = 20; goto _test_eof;
606 0           _test_eof21: cs = 21; goto _test_eof;
607 0           _test_eof22: cs = 22; goto _test_eof;
608 0           _test_eof23: cs = 23; goto _test_eof;
609 0           _test_eof24: cs = 24; goto _test_eof;
610 0           _test_eof25: cs = 25; goto _test_eof;
611 10           _test_eof38: cs = 38; goto _test_eof;
612 0           _test_eof26: cs = 26; goto _test_eof;
613 0           _test_eof27: cs = 27; goto _test_eof;
614 26           _test_eof39: cs = 39; goto _test_eof;
615 0           _test_eof28: cs = 28; goto _test_eof;
616 0           _test_eof29: cs = 29; goto _test_eof;
617 0           _test_eof30: cs = 30; goto _test_eof;
618 0           _test_eof31: cs = 31; goto _test_eof;
619 0           _test_eof32: cs = 32; goto _test_eof;
620 0           _test_eof33: cs = 33; goto _test_eof;
621 0           _test_eof34: cs = 34; goto _test_eof;
622 0           _test_eof35: cs = 35; goto _test_eof;
623 0           _test_eof36: cs = 36; goto _test_eof;
624 0           _test_eof37: cs = 37; goto _test_eof;
625 9           _test_eof40: cs = 40; goto _test_eof;
626              
627 45           _test_eof: {}
628 45 50         if ( p == eof )
629             {
630 45           switch ( cs ) {
631 10           case 38:
632             #line 78 "ragel/tstr_common.rl"
633             {
634             if (!tstr_token_parse_tz_offset(mark, p - mark, &v)) {
635             result = TSTR_PARSE_ERR_OFFSET;
636             {p++; cs = 0; goto _out;}
637             }
638             tstr_parsed_set_offset(parsed, v);
639             }
640             break;
641             case 40:
642             #line 86 "ragel/tstr_common.rl"
643             {
644             tstr_parsed_set_tz_utc(parsed, mark, p - mark);
645             }
646             break;
647             case 39:
648             #line 94 "ragel/tstr_common.rl"
649             {
650             tstr_parsed_set_tz_annotation(parsed, mark, p - mark);
651             }
652             break;
653             #line 654 "tstr_cparse_rfc9557.c"
654             }
655             }
656              
657 45 50         _out: {}
658             }
659              
660             #line 47 "ragel/tstr_cparse_rfc9557.rl"
661              
662             if (result != TSTR_PARSE_OK)
663             return result;
664              
665             return (cs >= rfc9557_first_final) ? TSTR_PARSE_OK : TSTR_PARSE_NOMATCH;
666             }