rusty_lr_parser 4.2.1

grammar line parser for rusty_lr
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
use proc_macro2::Span;
use proc_macro2::TokenStream;

use quote::quote_spanned;

use crate::grammar::{Terminal, TerminalClass};
use crate::parser::args::IdentOrLiteral;
use crate::parser::location::Located;
use crate::parser::location::Location;
use rusty_lr_core::TerminalSymbol;

/// failed to feed() the token
#[derive(Debug)]
pub enum ParseArgError {
    /// feed() failed; `span` is the byte range `[start, end)` in the source
    MacroLineParse { location: Location, message: String },
}

#[derive(Debug)]
pub enum ArgError {
    /// multiple %moduleprefix in the same grammar
    MultipleModulePrefixDefinition(Vec<Location>),
    /// multiple %userdata in the same grammar
    MultipleUserDataDefinition(Vec<Location>),
    /// multiple %error in the same grammar
    MultipleErrorDefinition(Vec<Location>),
    /// multiple %tokentype in the same grammar
    MultipleTokenTypeDefinition(Vec<Location>),
    /// multiple %start in the same grammar
    MultipleStartDefinition(Vec<Location>),
    /// multiple %prec in the same rule
    MultiplePrecDefinition(Vec<Location>),
    /// multiple %dprec in the same rule
    MultipleDPrecDefinition(Vec<Location>),
    /// multiple %location in the same grammar
    MultipleLocationDefinition(Vec<Location>),

    StartNotDefined,
    TokenTypeNotDefined,

    /// duplicated name for terminal symbols or non-terminal symbols
    MultipleNameDefinition(String, Vec<Location>),

    /// can't use reserved keyword as token name
    ReservedName(Vec<Located<String>>),
}

#[derive(Debug)]
pub enum ConflictError {
    /// error building given CFG
    ShiftReduceConflict {
        term: String,
        reduce_rule: (usize, rusty_lr_core::production::Production<String, String>),
        shift_rules: Vec<(usize, rusty_lr_core::production::LR0Item<String, String>)>,
    },
    /// error building given CFG
    ReduceReduceConflict {
        lookahead: String,
        rule1: (usize, rusty_lr_core::production::Production<String, String>),
        rule2: (usize, rusty_lr_core::production::Production<String, String>),
    },
}

#[derive(Debug)]
pub enum ParseError {
    /// different reduce type applied to the same terminal symbol
    MultipleReduceDefinition(Vec<Located<rusty_lr_core::production::Associativity>>),

    InvalidTerminalRange {
        location: Location,
        start: (Located<String>, Terminal),
        end: (Located<String>, Terminal),
    },

    /// name given to %start not defined
    StartNonTerminalNotDefined(Location),

    /// unknown terminal symbol name
    TerminalNotDefined(Location),

    /// not supported literal type
    UnsupportedLiteralType(Location),

    /// range in literal terminal set is not valid; [first, last] with first > last
    InvalidLiteralRange(Location),

    /// TokenType in Literal mode is not supported
    TokenInLiteralMode(Vec<Location>),

    /// conflicts in precedence definition
    MultiplePrecedenceOrderDefinition(Vec<Location>),

    /// Precedence not defined for the given token
    PrecedenceNotDefined(IdentOrLiteral),

    /// ReduceAction must be defined but not defined
    RuleTypeDefinedButActionNotDefined { nonterm: Location, rule: Location },

    /// Only terminal or terminal set is allowed
    OnlyTerminalSet(Location),

    /// unknown non-terminal symbol name
    NonTerminalNotDefined(Location),

    /// only 'usize' literal is allowed for %dprec
    OnlyUsizeLiteral(Location),

    /// bison variable $0 is not supported
    BisonVariableZero(Location),

    /// bison variable is out of range
    BisonVariableOutOfRange {
        location: Location,
        name: String,
        max: usize,
    },

    /// type inference failed for NonTerminal's ruletype placeholder '_'
    TypeInferenceFailed(Location),

    /// Circular dependency detected in variable substitution
    CircularDependency {
        location: Location,
        path: Vec<String>,
    },

    /// Maximum variable substitution depth exceeded
    MaxSubstitutionDepthExceeded {
        location: Location,
        max_depth: usize,
    },

    /// unknown diagnostic name allowed
    InvalidAllowDiagnostic { location: Location, name: String },
}
impl ArgError {
    pub fn to_compile_error(
        &self,
        span_manager: &crate::parser::location::SpanManager,
    ) -> TokenStream {
        let mut output = TokenStream::new();
        let message = self.short_message();
        for loc in self.locations() {
            for span in span_manager.get_spans_in_location(&loc) {
                output.extend(quote_spanned! {
                    span=>
                    compile_error!(#message);
                });
            }
        }
        output
    }

    pub fn locations(&self) -> Vec<Location> {
        match self {
            ArgError::MultipleModulePrefixDefinition(locs)
            | ArgError::MultipleUserDataDefinition(locs)
            | ArgError::MultipleErrorDefinition(locs)
            | ArgError::MultipleTokenTypeDefinition(locs)
            | ArgError::MultipleLocationDefinition(locs)
            | ArgError::MultipleStartDefinition(locs)
            | ArgError::MultiplePrecDefinition(locs)
            | ArgError::MultipleDPrecDefinition(locs) => locs.clone(),
            ArgError::MultipleNameDefinition(_, locs) => locs.clone(),
            ArgError::ReservedName(names) => names.iter().map(|name| name.location()).collect(),
            _ => vec![Location::default()],
        }
    }

    pub fn short_message(&self) -> String {
        match self {
            ArgError::MultipleModulePrefixDefinition(_) => {
                "Multiple %moduleprefix definition".into()
            }
            ArgError::MultipleUserDataDefinition(_) => "Multiple %userdata definition".into(),
            ArgError::MultipleErrorDefinition(_) => "Multiple %error definition".into(),
            ArgError::MultipleTokenTypeDefinition(_) => "Multiple %tokentype definition".into(),
            ArgError::MultipleLocationDefinition(_) => "Multiple %location definition".into(),
            ArgError::MultipleStartDefinition(_) => "Multiple %start definition".into(),
            ArgError::MultiplePrecDefinition(_) => "Multiple %prec definition".into(),
            ArgError::MultipleDPrecDefinition(_) => "Multiple %dprec definition".into(),
            ArgError::StartNotDefined => "Start rule not defined\n>>> %start <rule_name>;".into(),
            ArgError::TokenTypeNotDefined => {
                "Token type not defined\n>>> %tokentype <token_type_name>;".into()
            }
            ArgError::MultipleNameDefinition(name, _) => {
                format!("Duplicated name for terminal or non-terminal: {}", name)
            }
            ArgError::ReservedName(_) => "This name is reserved and cannot be used".into(),
        }
    }
}
impl ParseArgError {
    pub fn to_compile_error(
        &self,
        span_manager: &crate::parser::location::SpanManager,
    ) -> TokenStream {
        let mut output = TokenStream::new();
        let message = self.short_message();
        let location = self.location();
        for span in span_manager.get_spans_in_location(&location) {
            output.extend(quote_spanned! {
                span=>
                compile_error!(#message);
            });
        }
        output
    }

    /// Returns the byte range `[start, end)` of the error location in the source.
    pub fn location(&self) -> Location {
        match self {
            ParseArgError::MacroLineParse { location, .. } => *location,
        }
    }

    pub fn short_message(&self) -> String {
        match self {
            ParseArgError::MacroLineParse { message, .. } => message.clone(),
        }
    }
}

impl ParseError {
    pub fn to_compile_error(
        &self,
        span_manager: &crate::parser::location::SpanManager,
    ) -> TokenStream {
        let mut output = TokenStream::new();
        let message = self.short_message();
        for loc in self.locations() {
            for span in span_manager.get_spans_in_location(&loc) {
                output.extend(quote_spanned! {
                    span=>
                    compile_error!(#message);
                });
            }
        }
        output
    }

    pub fn locations(&self) -> Vec<Location> {
        match self {
            ParseError::MultipleReduceDefinition(locations) => {
                locations.iter().map(Located::location).collect()
            }

            ParseError::InvalidTerminalRange { location, .. } => vec![*location],

            ParseError::StartNonTerminalNotDefined(loc) => vec![*loc],

            ParseError::TerminalNotDefined(loc) => vec![*loc],

            ParseError::UnsupportedLiteralType(loc) => vec![*loc],

            ParseError::InvalidLiteralRange(loc) => vec![*loc],

            ParseError::TokenInLiteralMode(locs) => locs.clone(),

            ParseError::MultiplePrecedenceOrderDefinition(locations) => locations.clone(),
            ParseError::PrecedenceNotDefined(name) => vec![name.location()],

            ParseError::RuleTypeDefinedButActionNotDefined { nonterm, rule } => {
                vec![*nonterm, *rule]
            }
            ParseError::OnlyTerminalSet(location) => vec![*location],
            ParseError::NonTerminalNotDefined(loc) => vec![*loc],
            ParseError::OnlyUsizeLiteral(loc) => vec![*loc],
            ParseError::BisonVariableZero(loc) => vec![*loc],
            ParseError::BisonVariableOutOfRange { location, .. } => vec![*location],
            ParseError::TypeInferenceFailed(location) => vec![*location],
            ParseError::CircularDependency { location, .. } => vec![*location],
            ParseError::MaxSubstitutionDepthExceeded { location, .. } => vec![*location],
            ParseError::InvalidAllowDiagnostic { location, .. } => vec![*location],
        }
    }

    pub fn short_message(&self) -> String {
        match self {
            ParseError::MultipleReduceDefinition(_) => {
                "Different reduce type (%left and %right) applied to the same terminal symbol".to_string()
            }

            ParseError::InvalidTerminalRange { location: _, start, end } => {
                format!(
                    "Invalid terminal range: [{}({}) - {}({})]",
                    start.0, start.1, end.0, end.1
                )
            }

            ParseError::StartNonTerminalNotDefined(_) => {
                "Name given to %start not defined".to_string()
            }

            ParseError::TerminalNotDefined(_) => {
                "Unknown terminal symbol name".to_string()
            }

            ParseError::UnsupportedLiteralType(_) => {

                format!("This literal type is not supported. Use string literal (e.g. 'a', \"abc\", b'a' or b\"abc\") instead")
            }

            ParseError::InvalidLiteralRange(_)=>"Invalid literal range: [first, last] with first > last".to_string(),


            ParseError::TokenInLiteralMode(_) => {
                "%token with %tokentype `char` or `u8` is not supported. Use character literal (e.g. 'a' or b'a') instead"
                    .to_string()
            }

            ParseError::MultiplePrecedenceOrderDefinition(_) => {
                "Multiple precedence order definition for the same token".to_string()
            }

            ParseError::PrecedenceNotDefined(_) => {
                "Precedence not defined for the given token".to_string()
            }


            ParseError::RuleTypeDefinedButActionNotDefined { .. } => {
                "ReduceAction must be defined for this rule".into()
            }
            ParseError::OnlyTerminalSet(_) => "Only terminal or terminal set is allowed".into(),
            ParseError::NonTerminalNotDefined(_) => {
                "Unknown non-terminal symbol name".to_string()
            }
            ParseError::OnlyUsizeLiteral(_) => "Only 'usize' literal is allowed for %dprec".into(),
            ParseError::BisonVariableZero(_) => "bison variable $0 is not supported".into(),
            ParseError::BisonVariableOutOfRange { name, max, .. } => {
                format!("bison variable {} is out of range (max: {})", name, max)
            }
            ParseError::TypeInferenceFailed(_) => {
                "Type inference failed for NonTerminal rule type".to_string()
            }
            ParseError::CircularDependency { path, .. } => {
                format!(
                    "Circular dependency detected in variable substitutions: {}",
                    path.join(" -> ")
                )
            }
            ParseError::MaxSubstitutionDepthExceeded { max_depth, .. } => {
                format!(
                    "Maximum variable substitution depth ({}) exceeded",
                    max_depth
                )
            }
            ParseError::InvalidAllowDiagnostic { name, .. } => {
                format!("unknown diagnostic name: `{}`", name)
            }
        }
    }
}

impl ConflictError {
    pub fn to_compile_error(&self) -> TokenStream {
        let span = self.span();
        let message = self.short_message();
        quote_spanned! {
            span=>
            compile_error!(#message);
        }
    }

    pub fn span(&self) -> Span {
        match self {
            ConflictError::ShiftReduceConflict { .. } => Span::call_site(),
            ConflictError::ReduceReduceConflict { .. } => Span::call_site(),
        }
    }

    pub fn short_message(&self) -> String {
        match self {
            ConflictError::ShiftReduceConflict {
                term,
                reduce_rule: (_, rule),
                shift_rules,
            } => {
                format!(
                    "Shift-Reduce conflict with terminal symbol: {}\n>>> Reduce: {}\n>>> Shifts: {}",
                    term,
                    rule,
                    shift_rules
                        .iter()
                        .map(|(_, rule)| format!("{}", rule))
                        .collect::<Vec<_>>()
                        .join("\n>>>")
                )
            }
            ConflictError::ReduceReduceConflict {
                lookahead,
                rule1: (_, rule1),
                rule2: (_, rule2),
            } => {
                format!(
                    "Reduce-Reduce conflict with lookahead symbol: {}\n>>> Rule1: {}\n>>> Rule2: {}",
                    lookahead, rule1, rule2
                )
            }
        }
    }
}

/// Represents various compilation warnings encountered during grammar analysis
/// and parser generation (e.g., unused symbols, cycles, etc.).
#[derive(Debug, Clone)]
pub enum Warning {
    NonTermUnreachable { nonterm_name: Located<String> },
    UnusedNonTermData { nonterm_name: Located<String> },
    NonTermUnproductive { nonterm_name: Located<String> },
    UnusedTerminals { class_idx: TerminalClass },
}

impl Warning {
    pub fn name(&self) -> &'static str {
        match self {
            Warning::NonTermUnreachable { .. } => "nonterm_unreachable",
            Warning::UnusedNonTermData { .. } => "unused_nonterm_data",
            Warning::NonTermUnproductive { .. } => "nonterm_unproductive",
            Warning::UnusedTerminals { .. } => "unused_terminals",
        }
    }

    pub fn suggestion(&self, grammar: &crate::grammar::Grammar) -> String {
        match self {
            Warning::NonTermUnreachable { nonterm_name }
            | Warning::UnusedNonTermData { nonterm_name }
            | Warning::NonTermUnproductive { nonterm_name } => {
                let name = nonterm_name.value();
                format!("%allow {}({});", self.name(), name)
            }
            Warning::UnusedTerminals { class_idx } => {
                let class_name = grammar.class_pretty_name_abbr(*class_idx);
                format!("%allow {}({});", self.name(), class_name)
            }
        }
    }

    /// Translates the warning into a `TokenStream` containing a compiler warning.
    /// Since Rust does not have a stable `compile_warning!` macro, this leverages
    /// a dummy deprecated struct definition mapped to the source code span
    /// where the warning originated, allowing stable Rust compilers to emit a diagnostic warning.
    pub fn to_compile_warning(
        &self,
        grammar: &crate::grammar::Grammar,
        span_manager: &crate::parser::location::SpanManager,
    ) -> TokenStream {
        if grammar.is_warning_allowed(self) {
            return TokenStream::new();
        }
        let mut output = TokenStream::new();
        let message = format!(
            "{} (to ignore, add `{}` to the grammar)",
            self.short_message(grammar),
            self.suggestion(grammar)
        );
        let locs = self.locations();
        if locs.is_empty() {
            let span = Span::call_site();
            output.extend(quote_spanned! {
                span=>
                const _: () = {
                    #[deprecated(since = "0.0.0", note = #message)]
                    struct Warning;
                    let _ = Warning;
                };
            });
        } else {
            for loc in locs {
                for span in span_manager.get_spans_in_location(&loc) {
                    output.extend(quote_spanned! {
                        span=>
                        const _: () = {
                            #[deprecated(since = "0.0.0", note = #message)]
                            struct Warning;
                            let _ = Warning;
                        };
                    });
                }
            }
        }
        output
    }

    /// Retrieves all source code locations associated with this warning.
    pub fn locations(&self) -> Vec<Location> {
        match self {
            Warning::NonTermUnreachable { nonterm_name } => vec![nonterm_name.location()],
            Warning::UnusedNonTermData { nonterm_name } => vec![nonterm_name.location()],
            Warning::NonTermUnproductive { nonterm_name } => vec![nonterm_name.location()],
            Warning::UnusedTerminals { .. } => Vec::new(),
        }
    }

    /// Formats a short diagnostic message describing the warning.
    pub fn short_message(&self, grammar: &crate::grammar::Grammar) -> String {
        match self {
            Warning::NonTermUnreachable { nonterm_name } => {
                let name = nonterm_name.value();
                format!("Non-terminal `{name}` is not reachable from the start symbol")
            }
            Warning::UnusedNonTermData { nonterm_name } => {
                let name = nonterm_name.value();
                format!("Non-terminal `{name}`'s data type is not used in any reduce action")
            }
            Warning::NonTermUnproductive { nonterm_name } => {
                let name = nonterm_name.value();
                format!("Non-terminal `{name}` is unproductive and cannot derive any sequence of terminals")
            }
            Warning::UnusedTerminals { class_idx } => {
                let class_name = grammar.class_pretty_name_abbr(*class_idx);
                format!("Terminals merged in class `{class_name}` are defined but not used in any production rule")
            }
        }
    }
}

/// Represents informational diagnostics and details collected during parser construction
/// and conflict resolution (e.g. terminals merged, conflicts resolved, backtraces for GLR).
#[derive(Debug, Clone)]
pub enum Info {
    TerminalsMerged {
        class_idx: TerminalClass,
    },
    RedundantRuleRemoved {
        rule_location: Location,
    },
    UnitProductionEliminated {
        nonterm_name: Located<String>,
        rule_location: Location,
    },
    ReduceReduceConflictResolved {
        max_priority: usize,
        reduce_rules: Vec<usize>,
        deleted_rules: Vec<usize>,
    },
    ShiftReduceConflictResolvedShift {
        term: TerminalSymbol<TerminalClass>,
        shift_prec: usize,
        shift_rules: Vec<usize>,
        reduce_rules: Vec<(usize, usize)>,
    },
    ShiftReduceConflictResolvedReduce {
        term: TerminalSymbol<TerminalClass>,
        shift_prec: usize,
        shift_rules: Vec<usize>,
        reduce_rules: Vec<(usize, usize)>,
    },
    ShiftReduceConflictGLR {
        term: TerminalSymbol<TerminalClass>,
        shift_rules: Vec<usize>,
        shift_rules_backtrace: Vec<String>,
        reduce_rules: Vec<(usize, Vec<String>)>,
    },
    ReduceReduceConflictGLR {
        terms: Vec<TerminalSymbol<TerminalClass>>,
        reduce_rules: Vec<(usize, Vec<String>)>,
    },
}

impl Info {
    pub fn name(&self) -> &'static str {
        match self {
            Info::TerminalsMerged { .. } => "terminals_merged",
            Info::RedundantRuleRemoved { .. } => "redundant_rule_removed",
            Info::UnitProductionEliminated { .. } => "unit_production_eliminated",
            Info::ReduceReduceConflictResolved { .. } => "reduce_reduce_conflict_resolved",
            Info::ShiftReduceConflictResolvedShift { .. } => "shift_reduce_conflict_resolved",
            Info::ShiftReduceConflictResolvedReduce { .. } => "shift_reduce_conflict_resolved",
            Info::ShiftReduceConflictGLR { .. } => "shift_reduce_conflict_glr",
            Info::ReduceReduceConflictGLR { .. } => "reduce_reduce_conflict_glr",
        }
    }

    pub fn suggestion(&self, grammar: &crate::grammar::Grammar) -> String {
        match self {
            Info::UnitProductionEliminated { nonterm_name, .. } => {
                let name = nonterm_name.value();
                format!("%allow {}({});", self.name(), name)
            }
            Info::RedundantRuleRemoved { rule_location } => {
                let mut name = String::new();
                for nonterm in &grammar.nonterminals {
                    for rule in &nonterm.rules {
                        if rule.location() == *rule_location {
                            name = nonterm.name.value().clone();
                            break;
                        }
                    }
                }
                if name.is_empty() {
                    format!("%allow {};", self.name())
                } else {
                    format!("%allow {}({});", self.name(), name)
                }
            }
            Info::TerminalsMerged { class_idx } => {
                let class_name = format!(
                    "TerminalClass{}",
                    grammar.terminal_classes[*class_idx].multiterm_counter
                );
                format!("%allow {}({});", self.name(), class_name)
            }
            Info::ReduceReduceConflictResolved { reduce_rules, .. } => {
                if let Some(&r) = reduce_rules.first() {
                    if let Some((nonterm, _)) = grammar.get_rule_by_id(r) {
                        return format!("%allow {}({});", self.name(), nonterm.name.value());
                    }
                }
                format!("%allow {};", self.name())
            }
            Info::ShiftReduceConflictResolvedShift { term, .. }
            | Info::ShiftReduceConflictResolvedReduce { term, .. }
            | Info::ShiftReduceConflictGLR { term, .. } => {
                let term_name = match term {
                    TerminalSymbol::Terminal(t) => grammar.class_pretty_name_abbr(*t),
                    TerminalSymbol::Error => "error".to_string(),
                    TerminalSymbol::Eof => "$".to_string(),
                };
                format!("%allow {}({});", self.name(), term_name)
            }
            Info::ReduceReduceConflictGLR { terms, .. } => {
                if let Some(term) = terms.first() {
                    let term_name = match term {
                        TerminalSymbol::Terminal(t) => grammar.class_pretty_name_abbr(*t),
                        TerminalSymbol::Error => "error".to_string(),
                        TerminalSymbol::Eof => "$".to_string(),
                    };
                    return format!("%allow {}({});", self.name(), term_name);
                }
                format!("%allow {};", self.name())
            }
        }
    }
}