1use self::RuleResult::{Failed, Matched};
2fn escape_default(s: &str) -> String {
3 s.chars().flat_map(|c: char| c.escape_default()).collect()
4}
5fn char_range_at(s: &str, pos: usize) -> (char, usize) {
6 let c: &char = &s[pos..].chars().next().unwrap();
7 let next_pos: usize = pos + c.len_utf8();
8 (*c, next_pos)
9}
10#[derive(Clone)]
11enum RuleResult<T> {
12 Matched(usize, T),
13 Failed,
14}
15#[derive(PartialEq, Eq, Debug, Clone)]
16pub struct ParseError {
17 pub line: usize,
18 pub column: usize,
19 pub offset: usize,
20 pub expected: ::std::collections::HashSet<&'static str>,
21}
22pub type ParseResult<T> = Result<T, ParseError>;
23impl ::std::fmt::Display for ParseError {
24 fn fmt(
25 &self,
26 fmt: &mut ::std::fmt::Formatter,
27 ) -> ::std::result::Result<(), ::std::fmt::Error> {
28 write!(fmt, "error at {}:{}: expected ", self.line, self.column)?;
29 if self.expected.len() == 0 {
30 write!(fmt, "EOF")?;
31 } else if self.expected.len() == 1 {
32 write!(
33 fmt,
34 "`{}`",
35 escape_default(self.expected.iter().next().unwrap())
36 )?;
37 } else {
38 let mut iter: Iter<'_, &str> = self.expected.iter();
39 write!(fmt, "one of `{}`", escape_default(iter.next().unwrap()))?;
40 for elem: &&str in iter {
41 write!(fmt, ", `{}`", escape_default(elem))?;
42 }
43 }
44 Ok(())
45 }
46}
47impl ::std::error::Error for ParseError {
48 fn description(&self) -> &str {
49 "parse error"
50 }
51}
52fn slice_eq(
53 input: &str,
54 state: &mut ParseState,
55 pos: usize,
56 m: &'static str,
57) -> RuleResult<()> {
58 #![inline]
59 #![allow(dead_code)]
60 let l: usize = m.len();
61 if input.len() >= pos + l && &input.as_bytes()[pos..pos + l] == m.as_bytes() {
62 Matched(pos + l, ())
63 } else {
64 state.mark_failure(pos, expected:m)
65 }
66}
67fn slice_eq_case_insensitive(
68 input: &str,
69 state: &mut ParseState,
70 pos: usize,
71 m: &'static str,
72) -> RuleResult<()> {
73 #![inline]
74 #![allow(dead_code)]
75 let mut used: usize = 0usize;
76 let mut input_iter: impl Iterator = input[pos..].chars().flat_map(|x: char| x.to_uppercase());
77 for m_char_upper: char in m.chars().flat_map(|x: char| x.to_uppercase()) {
78 used += m_char_upper.len_utf8();
79 let input_char_result: Option = input_iter.next();
80 if input_char_result.is_none() || input_char_result.unwrap() != m_char_upper {
81 return state.mark_failure(pos, expected:m);
82 }
83 }
84 Matched(pos + used, ())
85}
86fn any_char(input: &str, state: &mut ParseState, pos: usize) -> RuleResult<()> {
87 #![inline]
88 #![allow(dead_code)]
89 if input.len() > pos {
90 let (_, next: usize) = char_range_at(s:input, pos);
91 Matched(next, ())
92 } else {
93 state.mark_failure(pos, expected:"<character>")
94 }
95}
96fn pos_to_line(input: &str, pos: usize) -> (usize, usize) {
97 let before: &str = &input[..pos];
98 let line: usize = before.as_bytes().iter().filter(|&&c: u8| c == b'\n').count() + 1;
99 let col: usize = before.chars().rev().take_while(|&c: char| c != '\n').count() + 1;
100 (line, col)
101}
102impl<'input> ParseState<'input> {
103 fn mark_failure(&mut self, pos: usize, expected: &'static str) -> RuleResult<()> {
104 if self.suppress_fail == 0 {
105 if pos > self.max_err_pos {
106 self.max_err_pos = pos;
107 self.expected.clear();
108 }
109 if pos == self.max_err_pos {
110 self.expected.insert(expected);
111 }
112 }
113 Failed
114 }
115}
116struct ParseState<'input> {
117 max_err_pos: usize,
118 suppress_fail: usize,
119 expected: ::std::collections::HashSet<&'static str>,
120 _phantom: ::std::marker::PhantomData<&'input ()>,
121}
122impl<'input> ParseState<'input> {
123 fn new() -> ParseState<'input> {
124 ParseState {
125 max_err_pos: 0,
126 suppress_fail: 0,
127 expected: ::std::collections::HashSet::new(),
128 _phantom: ::std::marker::PhantomData,
129 }
130 }
131}
132
133fn __parse_discard_doubles<'input>(
134 __input: &'input str,
135 __state: &mut ParseState<'input>,
136 __pos: usize,
137) -> RuleResult<Option<&'input str>> {
138 #![allow(non_snake_case, unused)]
139 {
140 let __seq_res = {
141 let __choice_res = {
142 let __seq_res = slice_eq(__input, __state, __pos, "{");
143 match __seq_res {
144 Matched(__pos, _) => slice_eq(__input, __state, __pos, "{"),
145 Failed => Failed,
146 }
147 };
148 match __choice_res {
149 Matched(__pos, __value) => Matched(__pos, __value),
150 Failed => {
151 let __seq_res = slice_eq(__input, __state, __pos, "}");
152 match __seq_res {
153 Matched(__pos, _) => slice_eq(__input, __state, __pos, "}"),
154 Failed => Failed,
155 }
156 }
157 }
158 };
159 match __seq_res {
160 Matched(__pos, _) => Matched(__pos, { None }),
161 Failed => Failed,
162 }
163 }
164}
165
166fn __parse_placeholder_inner<'input>(
167 __input: &'input str,
168 __state: &mut ParseState<'input>,
169 __pos: usize,
170) -> RuleResult<Option<&'input str>> {
171 #![allow(non_snake_case, unused)]
172 {
173 let __seq_res = {
174 let str_start = __pos;
175 match {
176 let __seq_res = if __input.len() > __pos {
177 let (__ch, __next) = char_range_at(__input, __pos);
178 match __ch {
179 '{' => Matched(__next, ()),
180 _ => __state.mark_failure(__pos, "[{]"),
181 }
182 } else {
183 __state.mark_failure(__pos, "[{]")
184 };
185 match __seq_res {
186 Matched(__pos, _) => {
187 let __seq_res = {
188 let mut __repeat_pos = __pos;
189 loop {
190 let __pos = __repeat_pos;
191 let __step_res = {
192 let __seq_res = {
193 __state.suppress_fail += 1;
194 let __assert_res = if __input.len() > __pos {
195 let (__ch, __next) =
196 char_range_at(__input, __pos);
197 match __ch {
198 '{' | '}' => Matched(__next, ()),
199 _ => {
200 __state.mark_failure(__pos, "[{}]")
201 }
202 }
203 } else {
204 __state.mark_failure(__pos, "[{}]")
205 };
206 __state.suppress_fail -= 1;
207 match __assert_res {
208 Failed => Matched(__pos, ()),
209 Matched(..) => Failed,
210 }
211 };
212 match __seq_res {
213 Matched(__pos, _) => {
214 any_char(__input, __state, __pos)
215 }
216 Failed => Failed,
217 }
218 };
219 match __step_res {
220 Matched(__newpos, __value) => {
221 __repeat_pos = __newpos;
222 }
223 Failed => {
224 break;
225 }
226 }
227 }
228 Matched(__repeat_pos, ())
229 };
230 match __seq_res {
231 Matched(__pos, _) => {
232 if __input.len() > __pos {
233 let (__ch, __next) = char_range_at(__input, __pos);
234 match __ch {
235 '}' => Matched(__next, ()),
236 _ => __state.mark_failure(__pos, "[}]"),
237 }
238 } else {
239 __state.mark_failure(__pos, "[}]")
240 }
241 }
242 Failed => Failed,
243 }
244 }
245 Failed => Failed,
246 }
247 } {
248 Matched(__newpos, _) => {
249 Matched(__newpos, &__input[str_start..__newpos])
250 }
251 Failed => Failed,
252 }
253 };
254 match __seq_res {
255 Matched(__pos, n) => Matched(__pos, { Some(n) }),
256 Failed => Failed,
257 }
258 }
259}
260
261fn __parse_discard_any<'input>(
262 __input: &'input str,
263 __state: &mut ParseState<'input>,
264 __pos: usize,
265) -> RuleResult<Option<&'input str>> {
266 #![allow(non_snake_case, unused)]
267 {
268 let __seq_res: RuleResult<()> = any_char(input:__input, state:__state, pos:__pos);
269 match __seq_res {
270 Matched(__pos: usize, _) => Matched(__pos, { None }),
271 Failed => Failed,
272 }
273 }
274}
275
276fn __parse_arg<'input>(
277 __input: &'input str,
278 __state: &mut ParseState<'input>,
279 __pos: usize,
280) -> RuleResult<usize> {
281 #![allow(non_snake_case, unused)]
282 {
283 let __seq_res = {
284 let str_start = __pos;
285 match {
286 let mut __repeat_pos = __pos;
287 let mut __repeat_value = vec![];
288 loop {
289 let __pos = __repeat_pos;
290 let __step_res = if __input.len() > __pos {
291 let (__ch, __next) = char_range_at(__input, __pos);
292 match __ch {
293 '0'...'9' => Matched(__next, ()),
294 _ => __state.mark_failure(__pos, "[0-9]"),
295 }
296 } else {
297 __state.mark_failure(__pos, "[0-9]")
298 };
299 match __step_res {
300 Matched(__newpos, __value) => {
301 __repeat_pos = __newpos;
302 __repeat_value.push(__value);
303 }
304 Failed => {
305 break;
306 }
307 }
308 }
309 if __repeat_value.len() >= 1 {
310 Matched(__repeat_pos, ())
311 } else {
312 Failed
313 }
314 } {
315 Matched(__newpos, _) => {
316 Matched(__newpos, &__input[str_start..__newpos])
317 }
318 Failed => Failed,
319 }
320 };
321 match __seq_res {
322 Matched(__pos, n) => Matched(__pos, { n.parse().unwrap() }),
323 Failed => Failed,
324 }
325 }
326}
327
328fn __parse_ty<'input>(
329 __input: &'input str,
330 __state: &mut ParseState<'input>,
331 __pos: usize,
332) -> RuleResult<&'input str> {
333 #![allow(non_snake_case, unused)]
334 {
335 let __seq_res = {
336 let str_start = __pos;
337 match {
338 let __choice_res = {
339 let __choice_res = slice_eq(__input, __state, __pos, "x?");
340 match __choice_res {
341 Matched(__pos, __value) => Matched(__pos, __value),
342 Failed => slice_eq(__input, __state, __pos, "X?"),
343 }
344 };
345 match __choice_res {
346 Matched(__pos, __value) => Matched(__pos, __value),
347 Failed => {
348 let __choice_res = slice_eq(__input, __state, __pos, "o");
349 match __choice_res {
350 Matched(__pos, __value) => Matched(__pos, __value),
351 Failed => {
352 let __choice_res =
353 slice_eq(__input, __state, __pos, "x");
354 match __choice_res {
355 Matched(__pos, __value) => Matched(__pos, __value),
356 Failed => {
357 let __choice_res =
358 slice_eq(__input, __state, __pos, "X");
359 match __choice_res {
360 Matched(__pos, __value) => {
361 Matched(__pos, __value)
362 }
363 Failed => {
364 let __choice_res = slice_eq(
365 __input, __state, __pos, "p",
366 );
367 match __choice_res {
368 Matched(__pos, __value) => {
369 Matched(__pos, __value)
370 }
371 Failed => {
372 let __choice_res = slice_eq(
373 __input, __state, __pos,
374 "b",
375 );
376 match __choice_res {
377 Matched(__pos, __value) => {
378 Matched(__pos, __value)
379 }
380 Failed => {
381 let __choice_res =
382 slice_eq(
383 __input,
384 __state, __pos,
385 "e",
386 );
387 match __choice_res {
388 Matched(
389 __pos,
390 __value,
391 ) => Matched(
392 __pos, __value,
393 ),
394 Failed => {
395 let __choice_res =
396 slice_eq(
397 __input,
398 __state,
399 __pos,
400 "E",
401 );
402 match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => slice_eq ( __input , __state , __pos , "?" ) }
403 }
404 }
405 }
406 }
407 }
408 }
409 }
410 }
411 }
412 }
413 }
414 }
415 }
416 }
417 } {
418 Matched(__newpos, _) => {
419 Matched(__newpos, &__input[str_start..__newpos])
420 }
421 Failed => Failed,
422 }
423 };
424 match __seq_res {
425 Matched(__pos, n) => Matched(__pos, { n }),
426 Failed => Failed,
427 }
428 }
429}
430
431fn __parse_format_spec<'input>(
432 __input: &'input str,
433 __state: &mut ParseState<'input>,
434 __pos: usize,
435) -> RuleResult<Option<&'input str>> {
436 #![allow(non_snake_case, unused)]
437 {
438 let __seq_res = slice_eq(__input, __state, __pos, ":");
439 match __seq_res {
440 Matched(__pos, _) => {
441 let __seq_res = match {
442 let __seq_res = match {
443 let __seq_res = {
444 __state.suppress_fail += 1;
445 let __assert_res = if __input.len() > __pos {
446 let (__ch, __next) = char_range_at(__input, __pos);
447 match __ch {
448 '<' | '^' | '>' => Matched(__next, ()),
449 _ => __state.mark_failure(__pos, "[<^>]"),
450 }
451 } else {
452 __state.mark_failure(__pos, "[<^>]")
453 };
454 __state.suppress_fail -= 1;
455 match __assert_res {
456 Failed => Matched(__pos, ()),
457 Matched(..) => Failed,
458 }
459 };
460 match __seq_res {
461 Matched(__pos, _) => any_char(__input, __state, __pos),
462 Failed => Failed,
463 }
464 } {
465 Matched(__newpos, _) => Matched(__newpos, ()),
466 Failed => Matched(__pos, ()),
467 };
468 match __seq_res {
469 Matched(__pos, _) => {
470 if __input.len() > __pos {
471 let (__ch, __next) = char_range_at(__input, __pos);
472 match __ch {
473 '<' | '^' | '>' => Matched(__next, ()),
474 _ => __state.mark_failure(__pos, "[<^>]"),
475 }
476 } else {
477 __state.mark_failure(__pos, "[<^>]")
478 }
479 }
480 Failed => Failed,
481 }
482 } {
483 Matched(__newpos, _) => Matched(__newpos, ()),
484 Failed => Matched(__pos, ()),
485 };
486 match __seq_res {
487 Matched(__pos, _) => {
488 let __seq_res = match {
489 let __choice_res = slice_eq(__input, __state, __pos, "+");
490 match __choice_res {
491 Matched(__pos, __value) => Matched(__pos, __value),
492 Failed => slice_eq(__input, __state, __pos, "-"),
493 }
494 } {
495 Matched(__newpos, _) => Matched(__newpos, ()),
496 Failed => Matched(__pos, ()),
497 };
498 match __seq_res {
499 Matched(__pos, _) => {
500 let __seq_res =
501 match slice_eq(__input, __state, __pos, "#") {
502 Matched(__newpos, _) => Matched(__newpos, ()),
503 Failed => Matched(__pos, ()),
504 };
505 match __seq_res {
506 Matched(__pos, _) => {
507 let __seq_res = match {
508 let __choice_res = {
509 let __seq_res = {
510 let mut __repeat_pos = __pos;
511 let mut __repeat_value = vec![];
512 loop {
513 let __pos = __repeat_pos;
514 let __step_res =
515 if __input.len() > __pos {
516 let (__ch, __next) =
517 char_range_at(
518 __input, __pos,
519 );
520 match __ch {
521 'A'...'Z'
522 | 'a'...'z'
523 | '0'...'9'
524 | '_' => Matched(
525 __next,
526 (),
527 ),
528 _ => __state
529 .mark_failure(
530 __pos,
531 "[A-Za-z0-9_]",
532 ),
533 }
534 } else {
535 __state.mark_failure(
536 __pos,
537 "[A-Za-z0-9_]",
538 )
539 };
540 match __step_res {
541 Matched(
542 __newpos,
543 __value,
544 ) => {
545 __repeat_pos = __newpos;
546 __repeat_value
547 .push(__value);
548 }
549 Failed => {
550 break;
551 }
552 }
553 }
554 if __repeat_value.len() >= 1 {
555 Matched(__repeat_pos, ())
556 } else {
557 Failed
558 }
559 };
560 match __seq_res {
561 Matched(__pos, _) => slice_eq(
562 __input, __state, __pos, "$",
563 ),
564 Failed => Failed,
565 }
566 };
567 match __choice_res {
568 Matched(__pos, __value) => {
569 Matched(__pos, __value)
570 }
571 Failed => {
572 let mut __repeat_pos = __pos;
573 let mut __repeat_value = vec![];
574 loop {
575 let __pos = __repeat_pos;
576 let __step_res = if __input
577 .len()
578 > __pos
579 {
580 let (__ch, __next) =
581 char_range_at(
582 __input, __pos,
583 );
584 match __ch {
585 '0'...'9' => {
586 Matched(__next, ())
587 }
588 _ => __state
589 .mark_failure(
590 __pos, "[0-9]",
591 ),
592 }
593 } else {
594 __state.mark_failure(
595 __pos, "[0-9]",
596 )
597 };
598 match __step_res {
599 Matched(
600 __newpos,
601 __value,
602 ) => {
603 __repeat_pos = __newpos;
604 __repeat_value
605 .push(__value);
606 }
607 Failed => {
608 break;
609 }
610 }
611 }
612 if __repeat_value.len() >= 1 {
613 Matched(__repeat_pos, ())
614 } else {
615 Failed
616 }
617 }
618 }
619 } {
620 Matched(__newpos, _) => {
621 Matched(__newpos, ())
622 }
623 Failed => Matched(__pos, ()),
624 };
625 match __seq_res {
626 Matched(__pos, _) => {
627 let __seq_res = match slice_eq(
628 __input, __state, __pos, "0",
629 ) {
630 Matched(__newpos, _) => {
631 Matched(__newpos, ())
632 }
633 Failed => Matched(__pos, ()),
634 };
635 match __seq_res {
636 Matched(__pos, _) => {
637 let __seq_res = match {
638 let __seq_res = slice_eq(
639 __input, __state,
640 __pos, ".",
641 );
642 match __seq_res {
643 Matched(__pos, _) => {
644 let __choice_res = {
645 let __seq_res = {
646 let mut
647 __repeat_pos =
648 __pos;
649 let mut
650 __repeat_value =
651 vec![];
652 loop {
653 let __pos = __repeat_pos ;
654 let __step_res = if __input . len ( ) > __pos { let ( __ch , __next ) = char_range_at ( __input , __pos ) ; match __ch { 'A' ... 'Z' | 'a' ... 'z' | '0' ... '9' | '_' => Matched ( __next , ( ) ) , _ => __state . mark_failure ( __pos , "[A-Za-z0-9_]" ) , } } else { __state . mark_failure ( __pos , "[A-Za-z0-9_]" ) } ;
655 match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; __repeat_value . push ( __value ) ; } , Failed => { break ; } }
656 }
657 if __repeat_value . len ( ) >= 1 { Matched ( __repeat_pos , ( ) ) } else { Failed }
658 };
659 match __seq_res { Matched ( __pos , _ ) => { slice_eq ( __input , __state , __pos , "$" ) } Failed => Failed , }
660 };
661 match __choice_res {
662 Matched(
663 __pos,
664 __value,
665 ) => Matched(
666 __pos,
667 __value,
668 ),
669 Failed => {
670 let __choice_res = {
671 let mut __repeat_pos = __pos ;
672 let mut
673 __repeat_value = vec![];
674 loop {
675 let __pos = __repeat_pos ;
676 let __step_res = if __input . len ( ) > __pos { let ( __ch , __next ) = char_range_at ( __input , __pos ) ; match __ch { '0' ... '9' => Matched ( __next , ( ) ) , _ => __state . mark_failure ( __pos , "[0-9]" ) , } } else { __state . mark_failure ( __pos , "[0-9]" ) } ;
677 match __step_res { Matched ( __newpos , __value ) => { __repeat_pos = __newpos ; __repeat_value . push ( __value ) ; } , Failed => { break ; } }
678 }
679 if __repeat_value . len ( ) >= 1 { Matched ( __repeat_pos , ( ) ) } else { Failed }
680 };
681 match __choice_res { Matched ( __pos , __value ) => Matched ( __pos , __value ) , Failed => slice_eq ( __input , __state , __pos , "*" ) }
682 }
683 }
684 }
685 Failed => Failed,
686 }
687 } {
688 Matched(__newpos, _) => {
689 Matched(__newpos, ())
690 }
691 Failed => {
692 Matched(__pos, ())
693 }
694 };
695 match __seq_res {
696 Matched(__pos, _) => {
697 let __seq_res =
698 match __parse_ty(
699 __input,
700 __state, __pos,
701 ) {
702 Matched(
703 __newpos,
704 __value,
705 ) => Matched(
706 __newpos,
707 Some(
708 __value,
709 ),
710 ),
711 Failed => {
712 Matched(
713 __pos,
714 None,
715 )
716 }
717 };
718 match __seq_res {
719 Matched(
720 __pos,
721 n,
722 ) => Matched(
723 __pos,
724 { n },
725 ),
726 Failed => Failed,
727 }
728 }
729 Failed => Failed,
730 }
731 }
732 Failed => Failed,
733 }
734 }
735 Failed => Failed,
736 }
737 }
738 Failed => Failed,
739 }
740 }
741 Failed => Failed,
742 }
743 }
744 Failed => Failed,
745 }
746 }
747 Failed => Failed,
748 }
749 }
750}
751
752fn __parse_all_placeholders<'input>(
753 __input: &'input str,
754 __state: &mut ParseState<'input>,
755 __pos: usize,
756) -> RuleResult<Vec<&'input str>> {
757 #![allow(non_snake_case, unused)]
758 {
759 let __seq_res = {
760 let mut __repeat_pos = __pos;
761 let mut __repeat_value = vec![];
762 loop {
763 let __pos = __repeat_pos;
764 let __step_res = {
765 let __choice_res = __parse_discard_doubles(__input, __state, __pos);
766 match __choice_res {
767 Matched(__pos, __value) => Matched(__pos, __value),
768 Failed => {
769 let __choice_res =
770 __parse_placeholder_inner(__input, __state, __pos);
771 match __choice_res {
772 Matched(__pos, __value) => Matched(__pos, __value),
773 Failed => __parse_discard_any(__input, __state, __pos),
774 }
775 }
776 }
777 };
778 match __step_res {
779 Matched(__newpos, __value) => {
780 __repeat_pos = __newpos;
781 __repeat_value.push(__value);
782 }
783 Failed => {
784 break;
785 }
786 }
787 }
788 Matched(__repeat_pos, __repeat_value)
789 };
790 match __seq_res {
791 Matched(__pos, x) => {
792 Matched(__pos, { x.into_iter().flat_map(|x| x).collect() })
793 }
794 Failed => Failed,
795 }
796 }
797}
798
799fn __parse_format<'input>(
800 __input: &'input str,
801 __state: &mut ParseState<'input>,
802 __pos: usize,
803) -> RuleResult<(Option<usize>, Option<&'input str>)> {
804 #![allow(non_snake_case, unused)]
805 {
806 let __seq_res = slice_eq(__input, __state, __pos, "{");
807 match __seq_res {
808 Matched(__pos, _) => {
809 let __seq_res = match __parse_arg(__input, __state, __pos) {
810 Matched(__newpos, __value) => Matched(__newpos, Some(__value)),
811 Failed => Matched(__pos, None),
812 };
813 match __seq_res {
814 Matched(__pos, n) => {
815 let __seq_res =
816 match __parse_format_spec(__input, __state, __pos) {
817 Matched(__newpos, __value) => {
818 Matched(__newpos, Some(__value))
819 }
820 Failed => Matched(__pos, None),
821 };
822 match __seq_res {
823 Matched(__pos, o) => {
824 let __seq_res = slice_eq(__input, __state, __pos, "}");
825 match __seq_res {
826 Matched(__pos, _) => {
827 Matched(__pos, { (n, o.and_then(|x| x)) })
828 }
829 Failed => Failed,
830 }
831 }
832 Failed => Failed,
833 }
834 }
835 Failed => Failed,
836 }
837 }
838 Failed => Failed,
839 }
840 }
841}
842
843pub fn all_placeholders<'input>(__input: &'input str) -> ParseResult<Vec<&'input str>> {
844 #![allow(non_snake_case, unused)]
845 let mut __state: ParseState<'_> = ParseState::new();
846 match __parse_all_placeholders(__input:__input, &mut __state, __pos:0) {
847 Matched(__pos: usize, __value: Vec<&str>) => {
848 if __pos == __input.len() {
849 return Ok(__value);
850 }
851 }
852 _ => {}
853 }
854 let (__line: usize, __col: usize) = pos_to_line(input:__input, __state.max_err_pos);
855 Err(ParseError {
856 line: __line,
857 column: __col,
858 offset: __state.max_err_pos,
859 expected: __state.expected,
860 })
861}
862
863pub fn format<'input>(
864 __input: &'input str,
865) -> ParseResult<(Option<usize>, Option<&'input str>)> {
866 #![allow(non_snake_case, unused)]
867 let mut __state: ParseState<'_> = ParseState::new();
868 match __parse_format(__input:__input, &mut __state, __pos:0) {
869 Matched(__pos: usize, __value: (Option, Option<&str>)) => {
870 if __pos == __input.len() {
871 return Ok(__value);
872 }
873 }
874 _ => {}
875 }
876 let (__line: usize, __col: usize) = pos_to_line(input:__input, __state.max_err_pos);
877 Err(ParseError {
878 line: __line,
879 column: __col,
880 offset: __state.max_err_pos,
881 expected: __state.expected,
882 })
883}
884