1
// auto-generated: "lalrpop 0.20.0"
2
// sha3: 701e228ccc68fcb86b5e6bc4719626fbfefefe31d323679d55e15d929f4a2974
3
use std::convert::TryInto;
4
use crate::Error;
5
use crate::packet::Any;
6
use crate::packet::Signature;
7
use crate::packet::UserID;
8
use crate::packet::UserAttribute;
9
use crate::packet::{key, Key};
10
use crate::packet::Unknown;
11
use crate::Packet;
12
use crate::policy::HashAlgoSecurity::SecondPreImageResistance;
13
use crate::cert::prelude::*;
14
use crate::cert::parser::low_level::lexer;
15
use crate::cert::parser::low_level::lexer::{Token, Component};
16
use crate::cert::parser::low_level::grammar_util::*;
17
use crate::cert::ComponentBundles;
18
use crate::cert::bundle::{
19
    PrimaryKeyBundle,
20
    SubkeyBundle,
21
    UserIDBundle,
22
    UserAttributeBundle,
23
    UnknownBundle,
24
};
25
use lalrpop_util::ParseError;
26
#[allow(unused_extern_crates)]
27
extern crate lalrpop_util as __lalrpop_util;
28
#[allow(unused_imports)]
29
use self::__lalrpop_util::state_machine as __state_machine;
30
extern crate core;
31
extern crate alloc;
32

            
33
#[rustfmt::skip]
34
#[allow(non_snake_case, non_camel_case_types, unused_mut, unused_variables, unused_imports, unused_parens, clippy::all)]
35
mod __parse__Cert {
36

            
37
    use std::convert::TryInto;
38
    use crate::Error;
39
    use crate::packet::Any;
40
    use crate::packet::Signature;
41
    use crate::packet::UserID;
42
    use crate::packet::UserAttribute;
43
    use crate::packet::{key, Key};
44
    use crate::packet::Unknown;
45
    use crate::Packet;
46
    use crate::policy::HashAlgoSecurity::SecondPreImageResistance;
47
    use crate::cert::prelude::*;
48
    use crate::cert::parser::low_level::lexer;
49
    use crate::cert::parser::low_level::lexer::{Token, Component};
50
    use crate::cert::parser::low_level::grammar_util::*;
51
    use crate::cert::ComponentBundles;
52
    use crate::cert::bundle::{
53
    PrimaryKeyBundle,
54
    SubkeyBundle,
55
    UserIDBundle,
56
    UserAttributeBundle,
57
    UnknownBundle,
58
};
59
    use lalrpop_util::ParseError;
60
    #[allow(unused_extern_crates)]
61
    extern crate lalrpop_util as __lalrpop_util;
62
    #[allow(unused_imports)]
63
    use self::__lalrpop_util::state_machine as __state_machine;
64
    extern crate core;
65
    extern crate alloc;
66
    use super::__ToTriple;
67
    #[allow(dead_code)]
68
    pub(crate) enum __Symbol<>
69
     {
70
        Variant0(lexer::Token),
71
        Variant1(Option<Cert>),
72
        Variant2(Option<Component>),
73
        Variant3(Option<Vec<Component>>),
74
        Variant4(Option<Vec<Signature>>),
75
        Variant5(Option<(Packet, Vec<Signature>)>),
76
        Variant6(Option<Packet>),
77
        Variant7(Option<PacketOrUnknown<Key<key::PublicParts, key::SubordinateRole>>>),
78
        Variant8(Option<Unknown>),
79
        Variant9(Option<PacketOrUnknown<UserAttribute>>),
80
        Variant10(Option<PacketOrUnknown<UserID>>),
81
    }
82
    const __ACTION: &[i8] = &[
83
        // State 0
84
        10, 0, 11, 0, 0, 0, 0, 0, 0,
85
        // State 1
86
        0, -6, 0, -6, 0, 0, -6, -6, -6,
87
        // State 2
88
        0, -8, 0, -8, -8, -8, -8, -8, -8,
89
        // State 3
90
        0, 14, 0, 15, 0, 0, 16, 17, 18,
91
        // State 4
92
        0, -8, 0, -8, -8, -8, -8, -8, -8,
93
        // State 5
94
        0, -8, 0, -8, -8, -8, -8, -8, -8,
95
        // State 6
96
        0, -8, 0, -8, -8, -8, -8, -8, -8,
97
        // State 7
98
        0, -8, 0, -8, -8, -8, -8, -8, -8,
99
        // State 8
100
        0, 0, 0, 0, 0, 0, 0, 0, 0,
101
        // State 9
102
        0, -12, 0, -12, -12, -12, -12, -12, -12,
103
        // State 10
104
        0, -13, 0, -13, -13, -13, -13, -13, -13,
105
        // State 11
106
        0, -11, 0, -11, 19, 20, -11, -11, -11,
107
        // State 12
108
        0, -7, 0, -7, 0, 0, -7, -7, -7,
109
        // State 13
110
        0, -14, 0, -14, -14, -14, -14, -14, -14,
111
        // State 14
112
        0, -15, 0, -15, -15, -15, -15, -15, -15,
113
        // State 15
114
        0, -16, 0, -16, -16, -16, -16, -16, -16,
115
        // State 16
116
        0, -18, 0, -18, -18, -18, -18, -18, -18,
117
        // State 17
118
        0, -17, 0, -17, -17, -17, -17, -17, -17,
119
        // State 18
120
        0, -9, 0, -9, -9, -9, -9, -9, -9,
121
        // State 19
122
        0, -10, 0, -10, -10, -10, -10, -10, -10,
123
        // State 20
124
        0, -2, 0, -2, 19, 20, -2, -2, -2,
125
        // State 21
126
        0, -5, 0, -5, 19, 20, -5, -5, -5,
127
        // State 22
128
        0, -4, 0, -4, 19, 20, -4, -4, -4,
129
        // State 23
130
        0, -3, 0, -3, 19, 20, -3, -3, -3,
131
    ];
132
352
    fn __action(state: i8, integer: usize) -> i8 {
133
352
        __ACTION[(state as usize) * 9 + integer]
134
352
    }
135
    const __EOF_ACTION: &[i8] = &[
136
        // State 0
137
        0,
138
        // State 1
139
        -6,
140
        // State 2
141
        -8,
142
        // State 3
143
        -1,
144
        // State 4
145
        -8,
146
        // State 5
147
        -8,
148
        // State 6
149
        -8,
150
        // State 7
151
        -8,
152
        // State 8
153
        -19,
154
        // State 9
155
        -12,
156
        // State 10
157
        -13,
158
        // State 11
159
        -11,
160
        // State 12
161
        -7,
162
        // State 13
163
        -14,
164
        // State 14
165
        -15,
166
        // State 15
167
        -16,
168
        // State 16
169
        -18,
170
        // State 17
171
        -17,
172
        // State 18
173
        -9,
174
        // State 19
175
        -10,
176
        // State 20
177
        -2,
178
        // State 21
179
        -5,
180
        // State 22
181
        -4,
182
        // State 23
183
        -3,
184
    ];
185
330
    fn __goto(state: i8, nt: usize) -> i8 {
186
330
        match nt {
187
22
            0 => 8,
188
44
            1 => 12,
189
66
            2 => 3,
190
110
            3 => match state {
191
44
                4 => 20,
192
                5 => 21,
193
                6 => 22,
194
44
                7 => 23,
195
22
                _ => 11,
196
            },
197
22
            4 => 1,
198
22
            5 => 2,
199
22
            6 => 4,
200
            7 => 5,
201
            8 => 6,
202
22
            9 => 7,
203
            _ => 0,
204
        }
205
330
    }
206
    const __TERMINAL: &[&str] = &[
207
        r###"PUBLIC_KEY"###,
208
        r###"PUBLIC_SUBKEY"###,
209
        r###"SECRET_KEY"###,
210
        r###"SECRET_SUBKEY"###,
211
        r###"SIGNATURE"###,
212
        r###"TRUST"###,
213
        r###"UNKNOWN"###,
214
        r###"USERID"###,
215
        r###"USER_ATTRIBUTE"###,
216
    ];
217
    fn __expected_tokens(__state: i8) -> alloc::vec::Vec<alloc::string::String> {
218
        __TERMINAL.iter().enumerate().filter_map(|(index, terminal)| {
219
            let next_state = __action(__state, index);
220
            if next_state == 0 {
221
                None
222
            } else {
223
                Some(alloc::string::ToString::to_string(terminal))
224
            }
225
        }).collect()
226
    }
227
    fn __expected_tokens_from_states<
228
    >(
229
        __states: &[i8],
230
        _: core::marker::PhantomData<()>,
231
    ) -> alloc::vec::Vec<alloc::string::String>
232
    {
233
        __TERMINAL.iter().enumerate().filter_map(|(index, terminal)| {
234
            if __accepts(None, __states, Some(index), core::marker::PhantomData::<()>) {
235
                Some(alloc::string::ToString::to_string(terminal))
236
            } else {
237
                None
238
            }
239
        }).collect()
240
    }
241
    pub(crate) struct __StateMachine<>
242
    where 
243
    {
244
        __phantom: core::marker::PhantomData<()>,
245
    }
246
    impl<> __state_machine::ParserDefinition for __StateMachine<>
247
    where 
248
    {
249
        type Location = usize;
250
        type Error = Error;
251
        type Token = lexer::Token;
252
        type TokenIndex = usize;
253
        type Symbol = __Symbol<>;
254
        type Success = Option<Cert>;
255
        type StateIndex = i8;
256
        type Action = i8;
257
        type ReduceIndex = i8;
258
        type NonterminalIndex = usize;
259

            
260
        #[inline]
261
22
        fn start_location(&self) -> Self::Location {
262
22
              Default::default()
263
22
        }
264

            
265
        #[inline]
266
22
        fn start_state(&self) -> Self::StateIndex {
267
22
              0
268
22
        }
269

            
270
        #[inline]
271
110
        fn token_to_index(&self, token: &Self::Token) -> Option<usize> {
272
110
            __token_to_integer(token, core::marker::PhantomData::<()>)
273
110
        }
274

            
275
        #[inline]
276
352
        fn action(&self, state: i8, integer: usize) -> i8 {
277
352
            __action(state, integer)
278
352
        }
279

            
280
        #[inline]
281
        fn error_action(&self, state: i8) -> i8 {
282
            __action(state, 9 - 1)
283
        }
284

            
285
        #[inline]
286
110
        fn eof_action(&self, state: i8) -> i8 {
287
110
            __EOF_ACTION[state as usize]
288
110
        }
289

            
290
        #[inline]
291
        fn goto(&self, state: i8, nt: usize) -> i8 {
292
            __goto(state, nt)
293
        }
294

            
295
110
        fn token_to_symbol(&self, token_index: usize, token: Self::Token) -> Self::Symbol {
296
110
            __token_to_symbol(token_index, token, core::marker::PhantomData::<()>)
297
110
        }
298

            
299
        fn expected_tokens(&self, state: i8) -> alloc::vec::Vec<alloc::string::String> {
300
            __expected_tokens(state)
301
        }
302

            
303
        fn expected_tokens_from_states(&self, states: &[i8]) -> alloc::vec::Vec<alloc::string::String> {
304
            __expected_tokens_from_states(states, core::marker::PhantomData::<()>)
305
        }
306

            
307
        #[inline]
308
        fn uses_error_recovery(&self) -> bool {
309
            false
310
        }
311

            
312
        #[inline]
313
        fn error_recovery_symbol(
314
            &self,
315
            recovery: __state_machine::ErrorRecovery<Self>,
316
        ) -> Self::Symbol {
317
            panic!("error recovery not enabled for this grammar")
318
        }
319

            
320
352
        fn reduce(
321
352
            &mut self,
322
352
            action: i8,
323
352
            start_location: Option<&Self::Location>,
324
352
            states: &mut alloc::vec::Vec<i8>,
325
352
            symbols: &mut alloc::vec::Vec<__state_machine::SymbolTriple<Self>>,
326
352
        ) -> Option<__state_machine::ParseResult<Self>> {
327
352
            __reduce(
328
352
                action,
329
352
                start_location,
330
352
                states,
331
352
                symbols,
332
352
                core::marker::PhantomData::<()>,
333
352
            )
334
352
        }
335

            
336
        fn simulate_reduce(&self, action: i8) -> __state_machine::SimulatedReduce<Self> {
337
            __simulate_reduce(action, core::marker::PhantomData::<()>)
338
        }
339
    }
340
    fn __token_to_integer<
341
    >(
342
        __token: &lexer::Token,
343
        _: core::marker::PhantomData<()>,
344
    ) -> Option<usize>
345
    {
346
110
        match *__token {
347
22
            lexer::Token::PublicKey(_) if true => Some(0),
348
22
            lexer::Token::PublicSubkey(_) if true => Some(1),
349
            lexer::Token::SecretKey(_) if true => Some(2),
350
            lexer::Token::SecretSubkey(_) if true => Some(3),
351
44
            lexer::Token::Signature(_) if true => Some(4),
352
            lexer::Token::Trust(_) if true => Some(5),
353
            lexer::Token::Unknown(_, _) if true => Some(6),
354
22
            lexer::Token::UserID(_) if true => Some(7),
355
            lexer::Token::UserAttribute(_) if true => Some(8),
356
            _ => None,
357
        }
358
110
    }
359
110
    fn __token_to_symbol<
360
110
    >(
361
110
        __token_index: usize,
362
110
        __token: lexer::Token,
363
110
        _: core::marker::PhantomData<()>,
364
110
    ) -> __Symbol<>
365
110
    {
366
110
        match __token_index {
367
110
            0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 => __Symbol::Variant0(__token),
368
            _ => unreachable!(),
369
        }
370
110
    }
371
    fn __simulate_reduce<
372
    >(
373
        __reduce_index: i8,
374
        _: core::marker::PhantomData<()>,
375
    ) -> __state_machine::SimulatedReduce<__StateMachine<>>
376
    {
377
        match __reduce_index {
378
            0 => {
379
                __state_machine::SimulatedReduce::Reduce {
380
                    states_to_pop: 2,
381
                    nonterminal_produced: 0,
382
                }
383
            }
384
            1 => {
385
                __state_machine::SimulatedReduce::Reduce {
386
                    states_to_pop: 2,
387
                    nonterminal_produced: 1,
388
                }
389
            }
390
            2 => {
391
                __state_machine::SimulatedReduce::Reduce {
392
                    states_to_pop: 2,
393
                    nonterminal_produced: 1,
394
                }
395
            }
396
            3 => {
397
                __state_machine::SimulatedReduce::Reduce {
398
                    states_to_pop: 2,
399
                    nonterminal_produced: 1,
400
                }
401
            }
402
            4 => {
403
                __state_machine::SimulatedReduce::Reduce {
404
                    states_to_pop: 2,
405
                    nonterminal_produced: 1,
406
                }
407
            }
408
            5 => {
409
                __state_machine::SimulatedReduce::Reduce {
410
                    states_to_pop: 0,
411
                    nonterminal_produced: 2,
412
                }
413
            }
414
            6 => {
415
                __state_machine::SimulatedReduce::Reduce {
416
                    states_to_pop: 2,
417
                    nonterminal_produced: 2,
418
                }
419
            }
420
            7 => {
421
                __state_machine::SimulatedReduce::Reduce {
422
                    states_to_pop: 0,
423
                    nonterminal_produced: 3,
424
                }
425
            }
426
            8 => {
427
                __state_machine::SimulatedReduce::Reduce {
428
                    states_to_pop: 2,
429
                    nonterminal_produced: 3,
430
                }
431
            }
432
            9 => {
433
                __state_machine::SimulatedReduce::Reduce {
434
                    states_to_pop: 2,
435
                    nonterminal_produced: 3,
436
                }
437
            }
438
            10 => {
439
                __state_machine::SimulatedReduce::Reduce {
440
                    states_to_pop: 2,
441
                    nonterminal_produced: 4,
442
                }
443
            }
444
            11 => {
445
                __state_machine::SimulatedReduce::Reduce {
446
                    states_to_pop: 1,
447
                    nonterminal_produced: 5,
448
                }
449
            }
450
            12 => {
451
                __state_machine::SimulatedReduce::Reduce {
452
                    states_to_pop: 1,
453
                    nonterminal_produced: 5,
454
                }
455
            }
456
            13 => {
457
                __state_machine::SimulatedReduce::Reduce {
458
                    states_to_pop: 1,
459
                    nonterminal_produced: 6,
460
                }
461
            }
462
            14 => {
463
                __state_machine::SimulatedReduce::Reduce {
464
                    states_to_pop: 1,
465
                    nonterminal_produced: 6,
466
                }
467
            }
468
            15 => {
469
                __state_machine::SimulatedReduce::Reduce {
470
                    states_to_pop: 1,
471
                    nonterminal_produced: 7,
472
                }
473
            }
474
            16 => {
475
                __state_machine::SimulatedReduce::Reduce {
476
                    states_to_pop: 1,
477
                    nonterminal_produced: 8,
478
                }
479
            }
480
            17 => {
481
                __state_machine::SimulatedReduce::Reduce {
482
                    states_to_pop: 1,
483
                    nonterminal_produced: 9,
484
                }
485
            }
486
            18 => __state_machine::SimulatedReduce::Accept,
487
            _ => panic!("invalid reduction index {}", __reduce_index)
488
        }
489
    }
490
    pub struct CertParser {
491
        _priv: (),
492
    }
493

            
494
    impl CertParser {
495
22
        pub fn new() -> CertParser {
496
22
            CertParser {
497
22
                _priv: (),
498
22
            }
499
22
        }
500

            
501
        #[allow(dead_code)]
502
22
        pub fn parse<
503
22
            __TOKEN: __ToTriple<>,
504
22
            __TOKENS: IntoIterator<Item=__TOKEN>,
505
22
        >(
506
22
            &self,
507
22
            __tokens0: __TOKENS,
508
22
        ) -> Result<Option<Cert>, __lalrpop_util::ParseError<usize, lexer::Token, Error>>
509
22
        {
510
22
            let __tokens = __tokens0.into_iter();
511
110
            let mut __tokens = __tokens.map(|t| __ToTriple::to_triple(t));
512
22
            __state_machine::Parser::drive(
513
22
                __StateMachine {
514
22
                    __phantom: core::marker::PhantomData::<()>,
515
22
                },
516
22
                __tokens,
517
22
            )
518
22
        }
519
    }
520
    fn __accepts<
521
    >(
522
        __error_state: Option<i8>,
523
        __states: &[i8],
524
        __opt_integer: Option<usize>,
525
        _: core::marker::PhantomData<()>,
526
    ) -> bool
527
    {
528
        let mut __states = __states.to_vec();
529
        __states.extend(__error_state);
530
        loop {
531
            let mut __states_len = __states.len();
532
            let __top = __states[__states_len - 1];
533
            let __action = match __opt_integer {
534
                None => __EOF_ACTION[__top as usize],
535
                Some(__integer) => __action(__top, __integer),
536
            };
537
            if __action == 0 { return false; }
538
            if __action > 0 { return true; }
539
            let (__to_pop, __nt) = match __simulate_reduce(-(__action + 1), core::marker::PhantomData::<()>) {
540
                __state_machine::SimulatedReduce::Reduce {
541
                    states_to_pop, nonterminal_produced
542
                } => (states_to_pop, nonterminal_produced),
543
                __state_machine::SimulatedReduce::Accept => return true,
544
            };
545
            __states_len -= __to_pop;
546
            __states.truncate(__states_len);
547
            let __top = __states[__states_len - 1];
548
            let __next_state = __goto(__top, __nt);
549
            __states.push(__next_state);
550
        }
551
    }
552
352
    pub(crate) fn __reduce<
553
352
    >(
554
352
        __action: i8,
555
352
        __lookahead_start: Option<&usize>,
556
352
        __states: &mut alloc::vec::Vec<i8>,
557
352
        __symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
558
352
        _: core::marker::PhantomData<()>,
559
352
    ) -> Option<Result<Option<Cert>,__lalrpop_util::ParseError<usize, lexer::Token, Error>>>
560
352
    {
561
352
        let (__pop_states, __nonterminal) = match __action {
562
            0 => {
563
                // Cert = Primary, OptionalComponents => ActionFn(1);
564
22
                assert!(__symbols.len() >= 2);
565
22
                let __sym1 = __pop_Variant3(__symbols);
566
22
                let __sym0 = __pop_Variant5(__symbols);
567
22
                let __start = __sym0.0;
568
22
                let __end = __sym1.2;
569
22
                let __nt = match super::__action1::<>(__sym0, __sym1) {
570
22
                    Ok(v) => v,
571
                    Err(e) => return Some(Err(e)),
572
                };
573
22
                __symbols.push((__start, __Symbol::Variant1(__nt), __end));
574
22
                (2, 0)
575
            }
576
            1 => {
577
22
                __reduce1(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
578
            }
579
            2 => {
580
22
                __reduce2(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
581
            }
582
            3 => {
583
                __reduce3(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
584
            }
585
            4 => {
586
                __reduce4(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
587
            }
588
            5 => {
589
22
                __reduce5(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
590
            }
591
            6 => {
592
44
                __reduce6(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
593
            }
594
            7 => {
595
66
                __reduce7(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
596
            }
597
            8 => {
598
44
                __reduce8(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
599
            }
600
            9 => {
601
                __reduce9(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
602
            }
603
            10 => {
604
22
                __reduce10(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
605
            }
606
            11 => {
607
22
                __reduce11(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
608
            }
609
            12 => {
610
                __reduce12(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
611
            }
612
            13 => {
613
22
                __reduce13(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
614
            }
615
            14 => {
616
                __reduce14(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
617
            }
618
            15 => {
619
                __reduce15(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
620
            }
621
            16 => {
622
                __reduce16(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
623
            }
624
            17 => {
625
22
                __reduce17(__lookahead_start, __symbols, core::marker::PhantomData::<()>)
626
            }
627
            18 => {
628
                // __Cert = Cert => ActionFn(0);
629
22
                let __sym0 = __pop_Variant1(__symbols);
630
22
                let __start = __sym0.0;
631
22
                let __end = __sym0.2;
632
22
                let __nt = super::__action0::<>(__sym0);
633
22
                return Some(Ok(__nt));
634
            }
635
            _ => panic!("invalid action code {}", __action)
636
        };
637
330
        let __states_len = __states.len();
638
330
        __states.truncate(__states_len - __pop_states);
639
330
        let __state = *__states.last().unwrap();
640
330
        let __next_state = __goto(__state, __nonterminal);
641
330
        __states.push(__next_state);
642
330
        None
643
352
    }
644
    #[inline(never)]
645
    fn __symbol_type_mismatch() -> ! {
646
        panic!("symbol type mismatch")
647
    }
648
22
    fn __pop_Variant5<
649
22
    >(
650
22
        __symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>
651
22
    ) -> (usize, Option<(Packet, Vec<Signature>)>, usize)
652
22
     {
653
22
        match __symbols.pop() {
654
22
            Some((__l, __Symbol::Variant5(__v), __r)) => (__l, __v, __r),
655
            _ => __symbol_type_mismatch()
656
        }
657
22
    }
658
22
    fn __pop_Variant1<
659
22
    >(
660
22
        __symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>
661
22
    ) -> (usize, Option<Cert>, usize)
662
22
     {
663
22
        match __symbols.pop() {
664
22
            Some((__l, __Symbol::Variant1(__v), __r)) => (__l, __v, __r),
665
            _ => __symbol_type_mismatch()
666
        }
667
22
    }
668
44
    fn __pop_Variant2<
669
44
    >(
670
44
        __symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>
671
44
    ) -> (usize, Option<Component>, usize)
672
44
     {
673
44
        match __symbols.pop() {
674
44
            Some((__l, __Symbol::Variant2(__v), __r)) => (__l, __v, __r),
675
            _ => __symbol_type_mismatch()
676
        }
677
44
    }
678
22
    fn __pop_Variant6<
679
22
    >(
680
22
        __symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>
681
22
    ) -> (usize, Option<Packet>, usize)
682
22
     {
683
22
        match __symbols.pop() {
684
22
            Some((__l, __Symbol::Variant6(__v), __r)) => (__l, __v, __r),
685
            _ => __symbol_type_mismatch()
686
        }
687
22
    }
688
22
    fn __pop_Variant7<
689
22
    >(
690
22
        __symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>
691
22
    ) -> (usize, Option<PacketOrUnknown<Key<key::PublicParts, key::SubordinateRole>>>, usize)
692
22
     {
693
22
        match __symbols.pop() {
694
22
            Some((__l, __Symbol::Variant7(__v), __r)) => (__l, __v, __r),
695
            _ => __symbol_type_mismatch()
696
        }
697
22
    }
698
    fn __pop_Variant9<
699
    >(
700
        __symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>
701
    ) -> (usize, Option<PacketOrUnknown<UserAttribute>>, usize)
702
     {
703
        match __symbols.pop() {
704
            Some((__l, __Symbol::Variant9(__v), __r)) => (__l, __v, __r),
705
            _ => __symbol_type_mismatch()
706
        }
707
    }
708
22
    fn __pop_Variant10<
709
22
    >(
710
22
        __symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>
711
22
    ) -> (usize, Option<PacketOrUnknown<UserID>>, usize)
712
22
     {
713
22
        match __symbols.pop() {
714
22
            Some((__l, __Symbol::Variant10(__v), __r)) => (__l, __v, __r),
715
            _ => __symbol_type_mismatch()
716
        }
717
22
    }
718
    fn __pop_Variant8<
719
    >(
720
        __symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>
721
    ) -> (usize, Option<Unknown>, usize)
722
     {
723
        match __symbols.pop() {
724
            Some((__l, __Symbol::Variant8(__v), __r)) => (__l, __v, __r),
725
            _ => __symbol_type_mismatch()
726
        }
727
    }
728
66
    fn __pop_Variant3<
729
66
    >(
730
66
        __symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>
731
66
    ) -> (usize, Option<Vec<Component>>, usize)
732
66
     {
733
66
        match __symbols.pop() {
734
66
            Some((__l, __Symbol::Variant3(__v), __r)) => (__l, __v, __r),
735
            _ => __symbol_type_mismatch()
736
        }
737
66
    }
738
110
    fn __pop_Variant4<
739
110
    >(
740
110
        __symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>
741
110
    ) -> (usize, Option<Vec<Signature>>, usize)
742
110
     {
743
110
        match __symbols.pop() {
744
110
            Some((__l, __Symbol::Variant4(__v), __r)) => (__l, __v, __r),
745
            _ => __symbol_type_mismatch()
746
        }
747
110
    }
748
110
    fn __pop_Variant0<
749
110
    >(
750
110
        __symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>
751
110
    ) -> (usize, lexer::Token, usize)
752
110
     {
753
110
        match __symbols.pop() {
754
110
            Some((__l, __Symbol::Variant0(__v), __r)) => (__l, __v, __r),
755
            _ => __symbol_type_mismatch()
756
        }
757
110
    }
758
22
    pub(crate) fn __reduce1<
759
22
    >(
760
22
        __lookahead_start: Option<&usize>,
761
22
        __symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
762
22
        _: core::marker::PhantomData<()>,
763
22
    ) -> (usize, usize)
764
22
    {
765
22
        // Component = Subkey, OptionalSignatures => ActionFn(10);
766
22
        assert!(__symbols.len() >= 2);
767
22
        let __sym1 = __pop_Variant4(__symbols);
768
22
        let __sym0 = __pop_Variant7(__symbols);
769
22
        let __start = __sym0.0;
770
22
        let __end = __sym1.2;
771
22
        let __nt = super::__action10::<>(__sym0, __sym1);
772
22
        __symbols.push((__start, __Symbol::Variant2(__nt), __end));
773
22
        (2, 1)
774
22
    }
775
22
    pub(crate) fn __reduce2<
776
22
    >(
777
22
        __lookahead_start: Option<&usize>,
778
22
        __symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
779
22
        _: core::marker::PhantomData<()>,
780
22
    ) -> (usize, usize)
781
22
    {
782
22
        // Component = UserID, OptionalSignatures => ActionFn(11);
783
22
        assert!(__symbols.len() >= 2);
784
22
        let __sym1 = __pop_Variant4(__symbols);
785
22
        let __sym0 = __pop_Variant10(__symbols);
786
22
        let __start = __sym0.0;
787
22
        let __end = __sym1.2;
788
22
        let __nt = super::__action11::<>(__sym0, __sym1);
789
22
        __symbols.push((__start, __Symbol::Variant2(__nt), __end));
790
22
        (2, 1)
791
22
    }
792
    pub(crate) fn __reduce3<
793
    >(
794
        __lookahead_start: Option<&usize>,
795
        __symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
796
        _: core::marker::PhantomData<()>,
797
    ) -> (usize, usize)
798
    {
799
        // Component = UserAttribute, OptionalSignatures => ActionFn(12);
800
        assert!(__symbols.len() >= 2);
801
        let __sym1 = __pop_Variant4(__symbols);
802
        let __sym0 = __pop_Variant9(__symbols);
803
        let __start = __sym0.0;
804
        let __end = __sym1.2;
805
        let __nt = super::__action12::<>(__sym0, __sym1);
806
        __symbols.push((__start, __Symbol::Variant2(__nt), __end));
807
        (2, 1)
808
    }
809
    pub(crate) fn __reduce4<
810
    >(
811
        __lookahead_start: Option<&usize>,
812
        __symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
813
        _: core::marker::PhantomData<()>,
814
    ) -> (usize, usize)
815
    {
816
        // Component = Unknown, OptionalSignatures => ActionFn(13);
817
        assert!(__symbols.len() >= 2);
818
        let __sym1 = __pop_Variant4(__symbols);
819
        let __sym0 = __pop_Variant8(__symbols);
820
        let __start = __sym0.0;
821
        let __end = __sym1.2;
822
        let __nt = super::__action13::<>(__sym0, __sym1);
823
        __symbols.push((__start, __Symbol::Variant2(__nt), __end));
824
        (2, 1)
825
    }
826
22
    pub(crate) fn __reduce5<
827
22
    >(
828
22
        __lookahead_start: Option<&usize>,
829
22
        __symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
830
22
        _: core::marker::PhantomData<()>,
831
22
    ) -> (usize, usize)
832
22
    {
833
22
        // OptionalComponents =  => ActionFn(8);
834
22
        let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default();
835
22
        let __end = __start.clone();
836
22
        let __nt = super::__action8::<>(&__start, &__end);
837
22
        __symbols.push((__start, __Symbol::Variant3(__nt), __end));
838
22
        (0, 2)
839
22
    }
840
44
    pub(crate) fn __reduce6<
841
44
    >(
842
44
        __lookahead_start: Option<&usize>,
843
44
        __symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
844
44
        _: core::marker::PhantomData<()>,
845
44
    ) -> (usize, usize)
846
44
    {
847
44
        // OptionalComponents = OptionalComponents, Component => ActionFn(9);
848
44
        assert!(__symbols.len() >= 2);
849
44
        let __sym1 = __pop_Variant2(__symbols);
850
44
        let __sym0 = __pop_Variant3(__symbols);
851
44
        let __start = __sym0.0;
852
44
        let __end = __sym1.2;
853
44
        let __nt = super::__action9::<>(__sym0, __sym1);
854
44
        __symbols.push((__start, __Symbol::Variant3(__nt), __end));
855
44
        (2, 2)
856
44
    }
857
66
    pub(crate) fn __reduce7<
858
66
    >(
859
66
        __lookahead_start: Option<&usize>,
860
66
        __symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
861
66
        _: core::marker::PhantomData<()>,
862
66
    ) -> (usize, usize)
863
66
    {
864
66
        // OptionalSignatures =  => ActionFn(5);
865
66
        let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default();
866
66
        let __end = __start.clone();
867
66
        let __nt = super::__action5::<>(&__start, &__end);
868
66
        __symbols.push((__start, __Symbol::Variant4(__nt), __end));
869
66
        (0, 3)
870
66
    }
871
44
    pub(crate) fn __reduce8<
872
44
    >(
873
44
        __lookahead_start: Option<&usize>,
874
44
        __symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
875
44
        _: core::marker::PhantomData<()>,
876
44
    ) -> (usize, usize)
877
44
    {
878
44
        // OptionalSignatures = OptionalSignatures, SIGNATURE => ActionFn(6);
879
44
        assert!(__symbols.len() >= 2);
880
44
        let __sym1 = __pop_Variant0(__symbols);
881
44
        let __sym0 = __pop_Variant4(__symbols);
882
44
        let __start = __sym0.0;
883
44
        let __end = __sym1.2;
884
44
        let __nt = super::__action6::<>(__sym0, __sym1);
885
44
        __symbols.push((__start, __Symbol::Variant4(__nt), __end));
886
44
        (2, 3)
887
44
    }
888
    pub(crate) fn __reduce9<
889
    >(
890
        __lookahead_start: Option<&usize>,
891
        __symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
892
        _: core::marker::PhantomData<()>,
893
    ) -> (usize, usize)
894
    {
895
        // OptionalSignatures = OptionalSignatures, TRUST => ActionFn(7);
896
        assert!(__symbols.len() >= 2);
897
        let __sym1 = __pop_Variant0(__symbols);
898
        let __sym0 = __pop_Variant4(__symbols);
899
        let __start = __sym0.0;
900
        let __end = __sym1.2;
901
        let __nt = super::__action7::<>(__sym0, __sym1);
902
        __symbols.push((__start, __Symbol::Variant4(__nt), __end));
903
        (2, 3)
904
    }
905
22
    pub(crate) fn __reduce10<
906
22
    >(
907
22
        __lookahead_start: Option<&usize>,
908
22
        __symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
909
22
        _: core::marker::PhantomData<()>,
910
22
    ) -> (usize, usize)
911
22
    {
912
22
        // Primary = PrimaryKey, OptionalSignatures => ActionFn(2);
913
22
        assert!(__symbols.len() >= 2);
914
22
        let __sym1 = __pop_Variant4(__symbols);
915
22
        let __sym0 = __pop_Variant6(__symbols);
916
22
        let __start = __sym0.0;
917
22
        let __end = __sym1.2;
918
22
        let __nt = super::__action2::<>(__sym0, __sym1);
919
22
        __symbols.push((__start, __Symbol::Variant5(__nt), __end));
920
22
        (2, 4)
921
22
    }
922
22
    pub(crate) fn __reduce11<
923
22
    >(
924
22
        __lookahead_start: Option<&usize>,
925
22
        __symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
926
22
        _: core::marker::PhantomData<()>,
927
22
    ) -> (usize, usize)
928
22
    {
929
22
        // PrimaryKey = PUBLIC_KEY => ActionFn(3);
930
22
        let __sym0 = __pop_Variant0(__symbols);
931
22
        let __start = __sym0.0;
932
22
        let __end = __sym0.2;
933
22
        let __nt = super::__action3::<>(__sym0);
934
22
        __symbols.push((__start, __Symbol::Variant6(__nt), __end));
935
22
        (1, 5)
936
22
    }
937
    pub(crate) fn __reduce12<
938
    >(
939
        __lookahead_start: Option<&usize>,
940
        __symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
941
        _: core::marker::PhantomData<()>,
942
    ) -> (usize, usize)
943
    {
944
        // PrimaryKey = SECRET_KEY => ActionFn(4);
945
        let __sym0 = __pop_Variant0(__symbols);
946
        let __start = __sym0.0;
947
        let __end = __sym0.2;
948
        let __nt = super::__action4::<>(__sym0);
949
        __symbols.push((__start, __Symbol::Variant6(__nt), __end));
950
        (1, 5)
951
    }
952
22
    pub(crate) fn __reduce13<
953
22
    >(
954
22
        __lookahead_start: Option<&usize>,
955
22
        __symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
956
22
        _: core::marker::PhantomData<()>,
957
22
    ) -> (usize, usize)
958
22
    {
959
22
        // Subkey = PUBLIC_SUBKEY => ActionFn(14);
960
22
        let __sym0 = __pop_Variant0(__symbols);
961
22
        let __start = __sym0.0;
962
22
        let __end = __sym0.2;
963
22
        let __nt = super::__action14::<>(__sym0);
964
22
        __symbols.push((__start, __Symbol::Variant7(__nt), __end));
965
22
        (1, 6)
966
22
    }
967
    pub(crate) fn __reduce14<
968
    >(
969
        __lookahead_start: Option<&usize>,
970
        __symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
971
        _: core::marker::PhantomData<()>,
972
    ) -> (usize, usize)
973
    {
974
        // Subkey = SECRET_SUBKEY => ActionFn(15);
975
        let __sym0 = __pop_Variant0(__symbols);
976
        let __start = __sym0.0;
977
        let __end = __sym0.2;
978
        let __nt = super::__action15::<>(__sym0);
979
        __symbols.push((__start, __Symbol::Variant7(__nt), __end));
980
        (1, 6)
981
    }
982
    pub(crate) fn __reduce15<
983
    >(
984
        __lookahead_start: Option<&usize>,
985
        __symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
986
        _: core::marker::PhantomData<()>,
987
    ) -> (usize, usize)
988
    {
989
        // Unknown = UNKNOWN => ActionFn(18);
990
        let __sym0 = __pop_Variant0(__symbols);
991
        let __start = __sym0.0;
992
        let __end = __sym0.2;
993
        let __nt = super::__action18::<>(__sym0);
994
        __symbols.push((__start, __Symbol::Variant8(__nt), __end));
995
        (1, 7)
996
    }
997
    pub(crate) fn __reduce16<
998
    >(
999
        __lookahead_start: Option<&usize>,
        __symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
        _: core::marker::PhantomData<()>,
    ) -> (usize, usize)
    {
        // UserAttribute = USER_ATTRIBUTE => ActionFn(17);
        let __sym0 = __pop_Variant0(__symbols);
        let __start = __sym0.0;
        let __end = __sym0.2;
        let __nt = super::__action17::<>(__sym0);
        __symbols.push((__start, __Symbol::Variant9(__nt), __end));
        (1, 8)
    }
22
    pub(crate) fn __reduce17<
22
    >(
22
        __lookahead_start: Option<&usize>,
22
        __symbols: &mut alloc::vec::Vec<(usize,__Symbol<>,usize)>,
22
        _: core::marker::PhantomData<()>,
22
    ) -> (usize, usize)
22
    {
22
        // UserID = USERID => ActionFn(16);
22
        let __sym0 = __pop_Variant0(__symbols);
22
        let __start = __sym0.0;
22
        let __end = __sym0.2;
22
        let __nt = super::__action16::<>(__sym0);
22
        __symbols.push((__start, __Symbol::Variant10(__nt), __end));
22
        (1, 9)
22
    }
}
pub use self::__parse__Cert::CertParser;
#[allow(clippy::too_many_arguments)]
22
fn __action0<
22
>(
22
    (_, __0, _): (usize, Option<Cert>, usize),
22
) -> Option<Cert>
22
{
22
    __0
22
}
#[allow(clippy::too_many_arguments)]
fn __action1<
>(
    (_, p, _): (usize, Option<(Packet, Vec<Signature>)>, usize),
    (_, c, _): (usize, Option<Vec<Component>>, usize),
) -> Result<Option<Cert>,__lalrpop_util::ParseError<usize,lexer::Token,Error>>
{
    {
22
        match p {
            Some((Packet::PublicKey(_), _))
            | Some((Packet::SecretKey(_), _)) => {
22
                let (key, sigs) = match p {
22
                    Some((Packet::PublicKey(key), sigs)) => (key, sigs),
                    Some((Packet::SecretKey(key), sigs)) => (key.into(), sigs),
                    _ => unreachable!(),
                };
22
                let c = c.unwrap();
22
                let sec = key.hash_algo_security();
22

            
22
                let mut cert = Cert {
22
                    primary: PrimaryKeyBundle {
22
                        component: key,
22
                        hash_algo_security: sec,
22
                        self_signatures: vec![],
22
                        certifications: sigs,
22
                        attestations: vec![],
22
                        self_revocations: vec![],
22
                        other_revocations: vec![],
22
                    },
22
                    subkeys: ComponentBundles::new(),
22
                    userids: ComponentBundles::new(),
22
                    user_attributes: ComponentBundles::new(),
22
                    unknowns: ComponentBundles::new(),
22
                    bad: vec![],
22
                };
44
                for c in c.into_iter() {
44
                    match c {
22
                        Component::SubkeyBundle(b) =>
22
                            cert.subkeys.push(b),
22
                        Component::UserIDBundle(b) =>
22
                            cert.userids.push(b),
                        Component::UserAttributeBundle(b) =>
                            cert.user_attributes.push(b),
                        Component::UnknownBundle(b) =>
                            cert.unknowns.push(b),
                    }
                }
22
                Ok(Some(cert))
            }
            Some((Packet::Unknown(unknown), sigs)) => {
                let mut packets: Vec<Packet> = Default::default();
                packets.push(unknown.into());
                for sig in sigs {
                    packets.push(sig.into());
                }
                for c in c.unwrap_or_default().into_iter() {
                    match c {
                        Component::SubkeyBundle(b) =>
                            b.into_packets().for_each(|p| packets.push(p)),
                        Component::UserIDBundle(b) =>
                            b.into_packets().for_each(|p| packets.push(p)),
                        Component::UserAttributeBundle(b) =>
                            b.into_packets().for_each(|p| packets.push(p)),
                        Component::UnknownBundle(b) =>
                            b.into_packets().for_each(|p| packets.push(p)),
                    }
                }
                Err(ParseError::User {
                    error: Error::UnsupportedCert2(
                        "Unsupported primary key".into(),
                        packets),
                })
            }
            None => {
                // Just validating a cert...
                assert!(c.is_none() || c.unwrap().len() == 0);
                Ok(None)
            }
            Some((pkt, _)) =>
              unreachable!("Expected key or unknown packet, got {:?}", pkt),
        }
    }
22
}
#[allow(clippy::too_many_arguments)]
fn __action2<
>(
    (_, pk, _): (usize, Option<Packet>, usize),
    (_, sigs, _): (usize, Option<Vec<Signature>>, usize),
) -> Option<(Packet, Vec<Signature>)>
{
    {
22
        if let Some(pk) = pk {
22
            Some((pk, sigs.unwrap()))
        } else {
            // Just validating a cert...
            assert!(sigs.is_none() || sigs.unwrap().len() == 0);
            None
        }
    }
22
}
#[allow(clippy::too_many_arguments)]
22
fn __action3<
22
>(
22
    (_, t, _): (usize, lexer::Token, usize),
22
) -> Option<Packet>
22
{
22
    t.into()
22
}
#[allow(clippy::too_many_arguments)]
fn __action4<
>(
    (_, t, _): (usize, lexer::Token, usize),
) -> Option<Packet>
{
    t.into()
}
#[allow(clippy::too_many_arguments)]
66
fn __action5<
66
>(
66
    __lookbehind: &usize,
66
    __lookahead: &usize,
66
) -> Option<Vec<Signature>>
66
{
66
    Some(vec![])
66
}
#[allow(clippy::too_many_arguments)]
fn __action6<
>(
    (_, sigs, _): (usize, Option<Vec<Signature>>, usize),
    (_, sig, _): (usize, lexer::Token, usize),
) -> Option<Vec<Signature>>
{
    {
44
        match sig {
44
            Token::Signature(Some(Packet::Signature(sig))) => {
44
                assert!(sigs.is_some());
44
                let mut sigs = sigs.unwrap();
44

            
44
                sigs.push(sig);
44
                Some(sigs)
            }
            Token::Signature(Some(Packet::Unknown(_sig))) => {
                // Ignore unsupported / bad signatures.
                assert!(sigs.is_some());
                sigs
            }
            // Just validating a cert...
            Token::Signature(None) => return None,
            tok => unreachable!("Expected signature token, got {:?}", tok),
        }
    }
44
}
#[allow(clippy::too_many_arguments)]
fn __action7<
>(
    (_, __0, _): (usize, Option<Vec<Signature>>, usize),
    (_, _, _): (usize, lexer::Token, usize),
) -> Option<Vec<Signature>>
{
    __0
}
#[allow(clippy::too_many_arguments)]
22
fn __action8<
22
>(
22
    __lookbehind: &usize,
22
    __lookahead: &usize,
22
) -> Option<Vec<Component>>
22
{
22
    Some(vec![])
22
}
#[allow(clippy::too_many_arguments)]
fn __action9<
>(
    (_, cs, _): (usize, Option<Vec<Component>>, usize),
    (_, c, _): (usize, Option<Component>, usize),
) -> Option<Vec<Component>>
{
    {
44
        if let Some(c) = c {
44
            let mut cs = cs.unwrap();
44
            cs.push(c);
44
            Some(cs)
        } else {
            // Just validating a cert...
            None
        }
    }
44
}
#[allow(clippy::too_many_arguments)]
fn __action10<
>(
    (_, key, _): (usize, Option<PacketOrUnknown<Key<key::PublicParts, key::SubordinateRole>>>, usize),
    (_, sigs, _): (usize, Option<Vec<Signature>>, usize),
) -> Option<Component>
{
    {
22
        match key {
22
            Some(Ok(key)) => {
22
                let sigs = sigs.unwrap();
22
                let sec = key.hash_algo_security();
22

            
22
                Some(Component::SubkeyBundle(SubkeyBundle {
22
                    component: key,
22
                    hash_algo_security: sec,
22
                    self_signatures: vec![],
22
                    certifications: sigs,
22
                    attestations: vec![],
22
                    self_revocations: vec![],
22
                    other_revocations: vec![],
22
                }))
            },
            Some(Err(u)) => Some(Component::UnknownBundle(UnknownBundle {
                component: u,
                hash_algo_security: SecondPreImageResistance,
                self_signatures: vec![],
                certifications: sigs.unwrap_or_default(),
                attestations: vec![],
                self_revocations: vec![],
                other_revocations: vec![],
            })),
            // Just validating a cert...
            None => None,
        }
    }
22
}
#[allow(clippy::too_many_arguments)]
fn __action11<
>(
    (_, u, _): (usize, Option<PacketOrUnknown<UserID>>, usize),
    (_, sigs, _): (usize, Option<Vec<Signature>>, usize),
) -> Option<Component>
{
    {
22
        match u {
22
            Some(Ok(u)) => {
22
                let sigs = sigs.unwrap();
22
                let sec = u.hash_algo_security();
22

            
22
                Some(Component::UserIDBundle(UserIDBundle {
22
                    component: u,
22
                    hash_algo_security: sec,
22
                    self_signatures: vec![],
22
                    certifications: sigs,
22
                    attestations: vec![],
22
                    self_revocations: vec![],
22
                    other_revocations: vec![],
22
                }))
            },
            Some(Err(u)) => Some(Component::UnknownBundle(UnknownBundle {
                component: u,
                hash_algo_security: SecondPreImageResistance,
                self_signatures: vec![],
                certifications: sigs.unwrap_or_default(),
                attestations: vec![],
                self_revocations: vec![],
                other_revocations: vec![],
            })),
            // Just validating a cert...
            None => None,
        }
    }
22
}
#[allow(clippy::too_many_arguments)]
fn __action12<
>(
    (_, u, _): (usize, Option<PacketOrUnknown<UserAttribute>>, usize),
    (_, sigs, _): (usize, Option<Vec<Signature>>, usize),
) -> Option<Component>
{
    {
        match u {
            Some(Ok(u)) => {
                let sigs = sigs.unwrap();
                let sec = u.hash_algo_security();
                Some(Component::UserAttributeBundle(UserAttributeBundle {
                    component: u,
                    hash_algo_security: sec,
                    self_signatures: vec![],
                    certifications: sigs,
                    attestations: vec![],
                    self_revocations: vec![],
                    other_revocations: vec![],
                }))
            },
            Some(Err(u)) => Some(Component::UnknownBundle(UnknownBundle {
                component: u,
                hash_algo_security: SecondPreImageResistance,
                self_signatures: vec![],
                certifications: sigs.unwrap_or_default(),
                attestations: vec![],
                self_revocations: vec![],
                other_revocations: vec![],
            })),
            // Just validating a cert...
            None => None,
        }
    }
}
#[allow(clippy::too_many_arguments)]
fn __action13<
>(
    (_, u, _): (usize, Option<Unknown>, usize),
    (_, sigs, _): (usize, Option<Vec<Signature>>, usize),
) -> Option<Component>
{
    {
        match u {
            Some(u) => {
                let sigs = sigs.unwrap();
                let sec = u.hash_algo_security();
                Some(Component::UnknownBundle(UnknownBundle {
                    component: u,
                    hash_algo_security: sec,
                    self_signatures: vec![],
                    certifications: sigs,
                    attestations: vec![],
                    self_revocations: vec![],
                    other_revocations: vec![],
                }))
            },
            // Just validating a cert...
            None => None,
        }
    }
}
#[allow(clippy::too_many_arguments)]
22
fn __action14<
22
>(
22
    (_, t, _): (usize, lexer::Token, usize),
22
) -> Option<PacketOrUnknown<Key<key::PublicParts, key::SubordinateRole>>>
22
{
22
    {
22
        match Option::<Packet>::from(t) {
22
            Some(p) => Some(p.downcast().map_err(
22
                |p| p.try_into().expect("infallible for unknown and this packet"))),
            // Just validating a cert...
            None => None,
        }
    }
22
}
#[allow(clippy::too_many_arguments)]
fn __action15<
>(
    (_, t, _): (usize, lexer::Token, usize),
) -> Option<PacketOrUnknown<Key<key::PublicParts, key::SubordinateRole>>>
{
    {
        match Option::<Packet>::from(t) {
            Some(p) => Some(Any::<key::SecretSubkey>::downcast(p)
                .map_err(
                    |p| p.try_into().expect("infallible for unknown and this packet"))
                .map(|sk| sk.parts_into_public())),
            // Just validating a cert...
            None => None,
        }
    }
}
#[allow(clippy::too_many_arguments)]
22
fn __action16<
22
>(
22
    (_, t, _): (usize, lexer::Token, usize),
22
) -> Option<PacketOrUnknown<UserID>>
22
{
22
    {
22
        match Option::<Packet>::from(t) {
22
            Some(p) => Some(p.downcast().map_err(
22
                |p| p.try_into().expect("infallible for unknown and this packet"))),
            // Just validating a cert...
            None => None,
        }
    }
22
}
#[allow(clippy::too_many_arguments)]
fn __action17<
>(
    (_, t, _): (usize, lexer::Token, usize),
) -> Option<PacketOrUnknown<UserAttribute>>
{
    {
        match Option::<Packet>::from(t) {
            Some(p) => Some(p.downcast().map_err(
                |p| p.try_into().expect("infallible for unknown and this packet"))),
            // Just validating a cert...
            None => None,
        }
    }
}
#[allow(clippy::too_many_arguments)]
fn __action18<
>(
    (_, t, _): (usize, lexer::Token, usize),
) -> Option<Unknown>
{
    {
        match Option::<Packet>::from(t) {
            Some(p) => p.try_into().ok(),
            // Just validating a cert...
            None => None,
        }
    }
}
#[allow(clippy::type_complexity)]
pub trait __ToTriple<>
{
    fn to_triple(value: Self) -> Result<(usize,lexer::Token,usize), __lalrpop_util::ParseError<usize, lexer::Token, Error>>;
}
impl<> __ToTriple<> for (usize, lexer::Token, usize)
{
    fn to_triple(value: Self) -> Result<(usize,lexer::Token,usize), __lalrpop_util::ParseError<usize, lexer::Token, Error>> {
        Ok(value)
    }
}
impl<> __ToTriple<> for Result<(usize, lexer::Token, usize), Error>
{
110
    fn to_triple(value: Self) -> Result<(usize,lexer::Token,usize), __lalrpop_util::ParseError<usize, lexer::Token, Error>> {
110
        match value {
110
            Ok(v) => Ok(v),
            Err(error) => Err(__lalrpop_util::ParseError::User { error }),
        }
110
    }
}