// @generated by antlr-rust-codegen v0.31.0 - do not edit
// project: https://github.com/ophi-dev/antlr-rust-runtime
antlr4_runtime::__antlr4_rust_require_codegen_api!(8, "0.31.0");
#[allow(warnings, missing_docs, clippy::all, clippy::pedantic, clippy::nursery)]
#[rustfmt::skip]
mod __antlr4_rust_generated {

use antlr4_runtime::token::TokenSource;
use antlr4_runtime::token_stream::CommonTokenStream;
use antlr4_runtime::atn::parser_atn::ParserAtn;
use antlr4_runtime::{BaseParser, GrammarMetadata, Parser, Recognizer};
use std::sync::OnceLock;
#[allow(unused_imports)]
use std::io::Write as _;
#[allow(unused_imports)]
use antlr4_runtime::{java_style_list, PredictionMode, BailErrorStrategy, TerminalNodeView as RuntimeTerminalNode, ErrorNodeView as RuntimeErrorNode, RuleNodeView, AsRuleNode, FromRuleNode, MissingChildError, Token as _};


pub const EOF: i32 = antlr4_runtime::TOKEN_EOF;
pub const WS: i32 = 1;
pub const NL: i32 = 2;
pub const COMMENT: i32 = 3;
pub const L_BRACKET: i32 = 4;
pub const DOUBLE_L_BRACKET: i32 = 5;
pub const R_BRACKET: i32 = 6;
pub const DOUBLE_R_BRACKET: i32 = 7;
pub const EQUALS: i32 = 8;
pub const DOT: i32 = 9;
pub const COMMA: i32 = 10;
pub const BASIC_STRING: i32 = 11;
pub const LITERAL_STRING: i32 = 12;
pub const UNQUOTED_KEY: i32 = 13;
pub const VALUE_WS: i32 = 14;
pub const L_BRACE: i32 = 15;
pub const BOOLEAN: i32 = 16;
pub const ML_BASIC_STRING: i32 = 17;
pub const ML_LITERAL_STRING: i32 = 18;
pub const FLOAT: i32 = 19;
pub const INF: i32 = 20;
pub const NAN: i32 = 21;
pub const DEC_INT: i32 = 22;
pub const HEX_INT: i32 = 23;
pub const OCT_INT: i32 = 24;
pub const BIN_INT: i32 = 25;
pub const OFFSET_DATE_TIME: i32 = 26;
pub const LOCAL_DATE_TIME: i32 = 27;
pub const LOCAL_DATE: i32 = 28;
pub const LOCAL_TIME: i32 = 29;
pub const INLINE_TABLE_WS: i32 = 30;
pub const R_BRACE: i32 = 31;
pub const ARRAY_WS: i32 = 32;

pub const RULE_DOCUMENT: usize = 0;
pub const RULE_EXPRESSION: usize = 1;
pub const RULE_COMMENT: usize = 2;
pub const RULE_KEY_VALUE: usize = 3;
pub const RULE_KEY: usize = 4;
pub const RULE_SIMPLE_KEY: usize = 5;
pub const RULE_UNQUOTED_KEY: usize = 6;
pub const RULE_QUOTED_KEY: usize = 7;
pub const RULE_DOTTED_KEY: usize = 8;
pub const RULE_VALUE: usize = 9;
pub const RULE_STRING: usize = 10;
pub const RULE_INTEGER: usize = 11;
pub const RULE_FLOATING_POINT: usize = 12;
pub const RULE_BOOL: usize = 13;
pub const RULE_DATE_TIME: usize = 14;
pub const RULE_ARRAY: usize = 15;
pub const RULE_ARRAY_VALUES: usize = 16;
pub const RULE_COMMENT_OR_NL: usize = 17;
pub const RULE_TABLE: usize = 18;
pub const RULE_STANDARD_TABLE: usize = 19;
pub const RULE_INLINE_TABLE: usize = 20;
pub const RULE_INLINE_TABLE_KEYVALS: usize = 21;
pub const RULE_INLINE_TABLE_KEYVALS_NON_EMPTY: usize = 22;
pub const RULE_ARRAY_TABLE: usize = 23;

pub static METADATA: GrammarMetadata = GrammarMetadata::new(
    "TomlParser",
    &["document", "expression", "comment", "key_value", "key", "simple_key", "unquoted_key", "quoted_key", "dotted_key", "value", "string", "integer", "floating_point", "bool_", "date_time", "array_", "array_values", "comment_or_nl", "table", "standard_table", "inline_table", "inline_table_keyvals", "inline_table_keyvals_non_empty", "array_table"],
    &[None, None, None, None, Some("\'[\'"), Some("\'[[\'"), Some("\']\'"), Some("\']]\'"), Some("\'=\'"), Some("\'.\'"), Some("\',\'"), None, None, None, None, Some("\'{\'"), None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, Some("\'}\'"), None],
    &[None, Some("WS"), Some("NL"), Some("COMMENT"), Some("L_BRACKET"), Some("DOUBLE_L_BRACKET"), Some("R_BRACKET"), Some("DOUBLE_R_BRACKET"), Some("EQUALS"), Some("DOT"), Some("COMMA"), Some("BASIC_STRING"), Some("LITERAL_STRING"), Some("UNQUOTED_KEY"), Some("VALUE_WS"), Some("L_BRACE"), Some("BOOLEAN"), Some("ML_BASIC_STRING"), Some("ML_LITERAL_STRING"), Some("FLOAT"), Some("INF"), Some("NAN"), Some("DEC_INT"), Some("HEX_INT"), Some("OCT_INT"), Some("BIN_INT"), Some("OFFSET_DATE_TIME"), Some("LOCAL_DATE_TIME"), Some("LOCAL_DATE"), Some("LOCAL_TIME"), Some("INLINE_TABLE_WS"), Some("R_BRACE"), Some("ARRAY_WS")],
    &[None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None],
    &[],
    &[],
    &[],
);

pub fn metadata() -> &'static GrammarMetadata {
    &METADATA
}

pub fn rule_names() -> &'static [&'static str] {
    METADATA.rule_names()
}

fn parser_semantics() -> &'static antlr4_runtime::ParserSemantics {
    static SEMANTICS_CELL: OnceLock<antlr4_runtime::ParserSemantics> = OnceLock::new();
    SEMANTICS_CELL.get_or_init(|| {
        let mut ir = antlr4_runtime::semir::SemIr::new();
        let mut predicates = Vec::new();

        let actions = Vec::new();
        antlr4_runtime::ParserSemantics { ir, predicates, actions }
    })
}




#[allow(dead_code)]
pub struct __GeneratedInput<'a, L: TokenSource>(&'a mut CommonTokenStream<L>);

#[allow(dead_code)]
impl<L: TokenSource> __GeneratedInput<'_, L> {
    pub fn text(&mut self) -> String {
        self.0.text_all()
    }

    pub fn la(&mut self, offset: isize) -> i32 {
        antlr4_runtime::IntStream::la(self.0, offset)
    }

    pub fn lt(&mut self, offset: isize) -> __GeneratedTokenView {
        __GeneratedTokenView {
            text: self
                .0
                .lt(offset)
                .map(|token| token.text_or_empty().to_owned())
                .unwrap_or_default(),
        }
    }
}

#[allow(dead_code)]
pub struct __GeneratedTokenView {
    text: String,
}

#[allow(dead_code)]
impl __GeneratedTokenView {
    pub fn text(&self) -> &str {
        &self.text
    }
}
#[allow(dead_code)]
#[derive(Clone)]
pub struct TerminalNode<'a> {
    __node: RuntimeTerminalNode<'a>,
}

#[allow(dead_code)]
impl<'a> TerminalNode<'a> {
    fn new(node: RuntimeTerminalNode<'a>) -> Self {
        Self { __node: node }
    }

    pub fn symbol(&self) -> antlr4_runtime::TokenView<'a> {
        self.__node.symbol()
    }

    pub fn is_error(&self) -> bool {
        matches!(
            self.__node.node().kind(),
            antlr4_runtime::NodeKind::Error
        )
    }

    pub fn is_missing(&self) -> bool {
        self.symbol().is_synthetic()
    }
}

impl std::fmt::Display for TerminalNode<'_> {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.__node.text())
    }
}

#[allow(dead_code)]
#[derive(Clone)]
pub struct ErrorNode<'a> {
    __node: RuntimeErrorNode<'a>,
}

#[allow(dead_code)]
impl<'a> ErrorNode<'a> {
    fn new(node: RuntimeErrorNode<'a>) -> Self {
        Self { __node: node }
    }

    pub fn symbol(&self) -> antlr4_runtime::TokenView<'a> {
        self.__node.symbol()
    }

    pub fn is_missing(&self) -> bool {
        self.symbol().is_synthetic()
    }
}

impl std::fmt::Display for ErrorNode<'_> {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.__node.text())
    }
}

#[allow(dead_code)]
#[derive(Clone, Copy)]
enum __GeneratedRuleContext<'a> {
    Stored(RuleNodeView<'a>),
    Active {
        context: &'a antlr4_runtime::ParserRuleContext,
        storage: &'a antlr4_runtime::ParseTreeStorage,
        tokens: &'a antlr4_runtime::TokenStore,
    },
}

#[doc(hidden)]
#[derive(Clone, Copy, Debug)]
pub struct StoredTreeContext;

#[derive(Clone, Copy, Debug)]
struct __ActiveParserContext;

#[allow(dead_code)]
fn __context_children<'a>(
    source: __GeneratedRuleContext<'a>,
) -> impl Iterator<Item = antlr4_runtime::Node<'a>> + 'a {
    let mut stored = match source {
        __GeneratedRuleContext::Stored(node) => Some(node.children()),
        __GeneratedRuleContext::Active { .. } => None,
    };
    let mut active = match source {
        __GeneratedRuleContext::Stored(_) => None,
        __GeneratedRuleContext::Active {
            context,
            storage,
            tokens,
        } => Some(context.child_nodes(storage, tokens)),
    };
    std::iter::from_fn(move || {
        stored
            .as_mut()
            .and_then(Iterator::next)
            .or_else(|| active.as_mut().and_then(Iterator::next))
    })
}

#[allow(dead_code)]
fn __rule_children<'a>(
    source: __GeneratedRuleContext<'a>,
    rule_index: usize,
) -> impl Iterator<Item = RuleNodeView<'a>> + 'a {
    __context_children(source).filter_map(move |child| {
        let rule = child.as_rule()?;
        (rule.rule_index() == rule_index).then_some(rule)
    })
}

// Keep this triage aligned with runtime `RuleNodeView::terminal_children()` and
// `ParserRuleContext::terminal_children()`.
fn __terminal_children<'a>(
    source: __GeneratedRuleContext<'a>,
) -> impl Iterator<Item = RuntimeTerminalNode<'a>> + 'a {
    __context_children(source).filter_map(|child| match child.kind() {
        antlr4_runtime::NodeKind::Terminal => child.as_terminal(),
        antlr4_runtime::NodeKind::Error => {
            child.as_error().map(antlr4_runtime::ErrorNodeView::terminal)
        }
        antlr4_runtime::NodeKind::Rule => None,
    })
}

#[allow(dead_code)]
fn __token_children<'a>(
    source: __GeneratedRuleContext<'a>,
    token_type: i32,
) -> impl Iterator<Item = RuntimeTerminalNode<'a>> + 'a {
    __terminal_children(source)
        .filter(move |terminal| terminal.symbol().token_type() == token_type)
}

#[allow(dead_code)]
fn __token_children_matching<'a>(
    source: __GeneratedRuleContext<'a>,
    token_types: &'static [i32],
) -> impl Iterator<Item = RuntimeTerminalNode<'a>> + 'a {
    __terminal_children(source)
        .filter(move |terminal| token_types.contains(&terminal.symbol().token_type()))
}

#[allow(dead_code)]
fn __labeled_token_child(
    child: antlr4_runtime::Node<'_>,
) -> Option<RuntimeTerminalNode<'_>> {
    match child.kind() {
        antlr4_runtime::NodeKind::Terminal => child.as_terminal(),
        antlr4_runtime::NodeKind::Error => {
            let terminal = child
                .as_error()
                .map(antlr4_runtime::ErrorNodeView::terminal)?;
            terminal.symbol().is_synthetic().then_some(terminal)
        }
        antlr4_runtime::NodeKind::Rule => None,
    }
}

#[allow(dead_code)]
fn __labeled_token_children<'a>(
    source: __GeneratedRuleContext<'a>,
    token_type: i32,
) -> impl Iterator<Item = RuntimeTerminalNode<'a>> + 'a {
    __context_children(source).filter_map(move |child| {
        let terminal = __labeled_token_child(child)?;
        (terminal.symbol().token_type() == token_type).then_some(terminal)
    })
}

#[allow(dead_code)]
fn __labeled_token_children_matching<'a>(
    source: __GeneratedRuleContext<'a>,
    token_types: &'static [i32],
) -> impl Iterator<Item = RuntimeTerminalNode<'a>> + 'a {
    __context_children(source).filter_map(move |child| {
        let terminal = __labeled_token_child(child)?;
        token_types
            .contains(&terminal.symbol().token_type())
            .then_some(terminal)
    })
}

#[allow(dead_code)]
trait __FromActiveRuleContext<'a>: Sized {
    fn __from_active(
        context: &'a antlr4_runtime::ParserRuleContext,
        live_attrs: Option<&dyn std::any::Any>,
        invocation_states: Vec<isize>,
        storage: &'a antlr4_runtime::ParseTreeStorage,
        tokens: &'a antlr4_runtime::TokenStore,
    ) -> Option<Self>;
}

#[allow(dead_code)]
fn __active_context_view<'a, T: __FromActiveRuleContext<'a>>(
    context: &'a antlr4_runtime::ParserRuleContext,
    invocation_states: Vec<isize>,
    storage: &'a antlr4_runtime::ParseTreeStorage,
    tokens: &'a antlr4_runtime::TokenStore,
) -> Option<T> {
    T::__from_active(context, None, invocation_states, storage, tokens)
}

#[allow(dead_code)]
fn __active_context_view_with_attrs<'a, T: __FromActiveRuleContext<'a>>(
    context: &'a antlr4_runtime::ParserRuleContext,
    live_attrs: &dyn std::any::Any,
    invocation_states: Vec<isize>,
    storage: &'a antlr4_runtime::ParseTreeStorage,
    tokens: &'a antlr4_runtime::TokenStore,
) -> Option<T> {
    T::__from_active(
        context,
        Some(live_attrs),
        invocation_states,
        storage,
        tokens,
    )
}

#[allow(dead_code)]
fn __write_invocation_states(
    f: &mut std::fmt::Formatter<'_>,
    states: impl Iterator<Item = isize>,
) -> std::fmt::Result {
    f.write_str("[")?;
    let mut separator = "";
    for state in states {
        write!(f, "{separator}{state}")?;
        separator = " ";
    }
    f.write_str("]")
}

/// Marker carried by generated contexts whose required-child
/// invariants were checked after a syntax-clean parse.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct ValidatedTreeContext {
    __private: (),
}

#[allow(dead_code)]
trait __RecoveryContextState {}

impl __RecoveryContextState for StoredTreeContext {}
impl __RecoveryContextState for __ActiveParserContext {}

/// A completed, syntax-clean parse tree whose generated child cardinalities
/// have been structurally validated.
#[derive(Debug)]
pub struct TomlValidatedTree {
    parsed: antlr4_runtime::ParsedFile,
}

impl TomlValidatedTree {
    fn __new(parsed: antlr4_runtime::ParsedFile) -> Self {
        Self { parsed }
    }

    /// Returns the validated entry-rule root.
    pub fn tree(&self) -> ValidatedRuleNode<'_> {
        let Some(rule) = self.parsed.tree().as_rule() else {
            unreachable!("validated parse root was checked as a rule node")
        };
        ValidatedRuleNode { __node: rule }
    }

    /// Borrows the underlying recovery-oriented parsed file.
    pub const fn parsed_file(&self) -> &antlr4_runtime::ParsedFile {
        &self.parsed
    }

    /// Drops the validation type boundary and returns the underlying parsed file.
    pub fn into_parsed_file(self) -> antlr4_runtime::ParsedFile {
        self.parsed
    }
}

/// A rule node borrowed from a [`TomlValidatedTree`].
#[derive(Clone, Copy, Debug)]
pub struct ValidatedRuleNode<'a> {
    __node: RuleNodeView<'a>,
}

impl<'a> ValidatedRuleNode<'a> {
    pub const fn rule_node(self) -> RuleNodeView<'a> {
        self.__node
    }

    pub const fn node(self) -> antlr4_runtime::Node<'a> {
        self.__node.node()
    }

    pub fn rule_index(self) -> usize {
        self.__node.rule_index()
    }

    pub fn text(self) -> String {
        self.__node.text()
    }

    pub fn downcast_ref<T: FromValidatedRuleNode<'a>>(self) -> Option<T> {
        T::from_validated_rule_node(self)
    }
}

/// Constructs a generated validated context from a validated rule node.
pub trait FromValidatedRuleNode<'a>: Sized {
    fn from_validated_rule_node(node: ValidatedRuleNode<'a>) -> Option<Self>;
}

/// Failure to recognize or validate a strict generated parse.
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum TomlValidationError {
    Recognition(antlr4_runtime::AntlrError),
    SyntaxErrors {
        lexer: usize,
        parser: usize,
    },
    MissingChild(MissingChildError),
    InvalidChildCount {
        context: &'static str,
        child: &'static str,
        minimum: usize,
        actual: usize,
    },
    RecoveredErrorNode {
        line: usize,
        column: usize,
        text: String,
    },
    InvalidRoot,
    UnknownRule {
        rule_index: usize,
    },
}

impl std::fmt::Display for TomlValidationError {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Self::Recognition(error) => write!(f, "parse failed: {error}"),
            Self::SyntaxErrors { lexer, parser } => write!(
                f,
                "parse produced {lexer} lexer and {parser} parser syntax errors"
            ),
            Self::MissingChild(error) => error.fmt(f),
            Self::InvalidChildCount {
                context,
                child,
                minimum,
                actual,
            } => write!(
                f,
                "required child {child} occurs {actual} times in {context}; expected at least {minimum}"
            ),
            Self::RecoveredErrorNode {
                line,
                column,
                text,
            } => write!(
                f,
                "recovered error node at {line}:{column}: {text}"
            ),
            Self::InvalidRoot => f.write_str("validated parse root is not a rule node"),
            Self::UnknownRule { rule_index } => write!(
                f,
                "parse tree contains unknown rule index {rule_index}"
            ),
        }
    }
}

impl std::error::Error for TomlValidationError {
    fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
        match self {
            Self::Recognition(error) => Some(error),
            Self::MissingChild(error) => Some(error),
            _ => None,
        }
    }
}

impl From<antlr4_runtime::AntlrError> for TomlValidationError {
    fn from(error: antlr4_runtime::AntlrError) -> Self {
        Self::Recognition(error)
    }
}

impl From<MissingChildError> for TomlValidationError {
    fn from(error: MissingChildError) -> Self {
        Self::MissingChild(error)
    }
}

#[allow(dead_code)]
fn __context_kind(context: RuleNodeView<'_>) -> usize {
    context.rule_index()
}

#[allow(dead_code)]
fn __active_context_kind(
    context: &antlr4_runtime::ParserRuleContext,
    _storage: &antlr4_runtime::ParseTreeStorage,
    _tokens: &antlr4_runtime::TokenStore,
) -> usize {
    context.rule_index()
}

antlr4_runtime::__antlr4_rust_context! {
    pub struct DocumentContext {
        rule_index: 0,
        context_kind: any,
        attributes: {
        },
        methods: {
            rule_node: rule_node,
            child_count: child_count,
            direct_terminals: direct_terminals,
            start: start,
            text: text,
        }
    }
}

antlr4_runtime::__antlr4_rust_context_accessors! {
    DocumentContext {
        rule expression_children: many(ExpressionContext[1]),
        token eof_token: required(-1, "EOF"),
        token nl_tokens: many(2),
    }
}

antlr4_runtime::__antlr4_rust_context! {
    pub struct ExpressionContext {
        rule_index: 1,
        context_kind: any,
        attributes: {
        },
        methods: {
            rule_node: rule_node,
            child_count: child_count,
            direct_terminals: direct_terminals,
            start: start,
            text: text,
        }
    }
}

antlr4_runtime::__antlr4_rust_context_accessors! {
    ExpressionContext {
        rule comment: required(CommentContext[2], "comment"),
        rule key_value: optional(KeyValueContext[3]),
        rule table: optional(TableContext[18]),
    }
}

antlr4_runtime::__antlr4_rust_context! {
    pub struct CommentContext {
        rule_index: 2,
        context_kind: any,
        attributes: {
        },
        methods: {
            rule_node: rule_node,
            child_count: child_count,
            direct_terminals: direct_terminals,
            start: start,
            text: text,
        }
    }
}

antlr4_runtime::__antlr4_rust_context_accessors! {
    CommentContext {
        token comment_token: optional(3),
    }
}

antlr4_runtime::__antlr4_rust_context! {
    pub struct KeyValueContext {
        rule_index: 3,
        context_kind: any,
        attributes: {
        },
        methods: {
            rule_node: rule_node,
            child_count: child_count,
            direct_terminals: direct_terminals,
            start: start,
            text: text,
        }
    }
}

antlr4_runtime::__antlr4_rust_context_accessors! {
    KeyValueContext {
        rule key: required(KeyContext[4], "key"),
        rule value: required(ValueContext[9], "value"),
        token equals_token: required(8, "EQUALS"),
    }
}

antlr4_runtime::__antlr4_rust_context! {
    pub struct KeyContext {
        rule_index: 4,
        context_kind: any,
        attributes: {
        },
        methods: {
            rule_node: rule_node,
            child_count: child_count,
            direct_terminals: direct_terminals,
            start: start,
            text: text,
        }
    }
}

antlr4_runtime::__antlr4_rust_context_accessors! {
    KeyContext {
        rule simple_key: optional(SimpleKeyContext[5]),
        rule dotted_key: optional(DottedKeyContext[8]),
    }
}

antlr4_runtime::__antlr4_rust_context! {
    pub struct SimpleKeyContext {
        rule_index: 5,
        context_kind: any,
        attributes: {
        },
        methods: {
            rule_node: rule_node,
            child_count: child_count,
            direct_terminals: direct_terminals,
            start: start,
            text: text,
        }
    }
}

antlr4_runtime::__antlr4_rust_context_accessors! {
    SimpleKeyContext {
        rule unquoted_key: optional(UnquotedKeyContext[6]),
        rule quoted_key: optional(QuotedKeyContext[7]),
    }
}

antlr4_runtime::__antlr4_rust_context! {
    pub struct UnquotedKeyContext {
        rule_index: 6,
        context_kind: any,
        attributes: {
        },
        methods: {
            rule_node: rule_node,
            child_count: child_count,
            direct_terminals: direct_terminals,
            start: start,
            text: text,
        }
    }
}

antlr4_runtime::__antlr4_rust_context_accessors! {
    UnquotedKeyContext {
        token unquoted_key_token: required(13, "UNQUOTED_KEY"),
    }
}

antlr4_runtime::__antlr4_rust_context! {
    pub struct QuotedKeyContext {
        rule_index: 7,
        context_kind: any,
        attributes: {
        },
        methods: {
            rule_node: rule_node,
            child_count: child_count,
            direct_terminals: direct_terminals,
            start: start,
            text: text,
        }
    }
}

antlr4_runtime::__antlr4_rust_context_accessors! {
    QuotedKeyContext {
        token basic_string_token: optional(11),
        token literal_string_token: optional(12),
    }
}

antlr4_runtime::__antlr4_rust_context! {
    pub struct DottedKeyContext {
        rule_index: 8,
        context_kind: any,
        attributes: {
        },
        methods: {
            rule_node: rule_node,
            child_count: child_count,
            direct_terminals: direct_terminals,
            start: start,
            text: text,
        }
    }
}

antlr4_runtime::__antlr4_rust_context_accessors! {
    DottedKeyContext {
        rule simple_key_children: many(SimpleKeyContext[5]),
        token dot_tokens: many(9),
    }
}

antlr4_runtime::__antlr4_rust_context! {
    pub struct ValueContext {
        rule_index: 9,
        context_kind: any,
        attributes: {
        },
        methods: {
            rule_node: rule_node,
            child_count: child_count,
            direct_terminals: direct_terminals,
            start: start,
            text: text,
        }
    }
}

antlr4_runtime::__antlr4_rust_context_accessors! {
    ValueContext {
        rule string: optional(StringContext[10]),
        rule integer: optional(IntegerContext[11]),
        rule floating_point: optional(FloatingPointContext[12]),
        rule bool: optional(BoolContext[13]),
        rule date_time: optional(DateTimeContext[14]),
        rule array: optional(ArrayContext[15]),
        rule inline_table: optional(InlineTableContext[20]),
    }
}

antlr4_runtime::__antlr4_rust_context! {
    pub struct StringContext {
        rule_index: 10,
        context_kind: any,
        attributes: {
        },
        methods: {
            rule_node: rule_node,
            child_count: child_count,
            direct_terminals: direct_terminals,
            start: start,
            text: text,
        }
    }
}

antlr4_runtime::__antlr4_rust_context_accessors! {
    StringContext {
        token basic_string_token: optional(11),
        token literal_string_token: optional(12),
        token ml_basic_string_token: optional(17),
        token ml_literal_string_token: optional(18),
    }
}

antlr4_runtime::__antlr4_rust_context! {
    pub struct IntegerContext {
        rule_index: 11,
        context_kind: any,
        attributes: {
        },
        methods: {
            rule_node: rule_node,
            child_count: child_count,
            direct_terminals: direct_terminals,
            start: start,
            text: text,
        }
    }
}

antlr4_runtime::__antlr4_rust_context_accessors! {
    IntegerContext {
        token dec_int_token: optional(22),
        token hex_int_token: optional(23),
        token oct_int_token: optional(24),
        token bin_int_token: optional(25),
    }
}

antlr4_runtime::__antlr4_rust_context! {
    pub struct FloatingPointContext {
        rule_index: 12,
        context_kind: any,
        attributes: {
        },
        methods: {
            rule_node: rule_node,
            child_count: child_count,
            direct_terminals: direct_terminals,
            start: start,
            text: text,
        }
    }
}

antlr4_runtime::__antlr4_rust_context_accessors! {
    FloatingPointContext {
        token float_token: optional(19),
        token inf_token: optional(20),
        token nan_token: optional(21),
    }
}

antlr4_runtime::__antlr4_rust_context! {
    pub struct BoolContext {
        rule_index: 13,
        context_kind: any,
        attributes: {
        },
        methods: {
            rule_node: rule_node,
            child_count: child_count,
            direct_terminals: direct_terminals,
            start: start,
            text: text,
        }
    }
}

antlr4_runtime::__antlr4_rust_context_accessors! {
    BoolContext {
        token boolean_token: required(16, "BOOLEAN"),
    }
}

antlr4_runtime::__antlr4_rust_context! {
    pub struct DateTimeContext {
        rule_index: 14,
        context_kind: any,
        attributes: {
        },
        methods: {
            rule_node: rule_node,
            child_count: child_count,
            direct_terminals: direct_terminals,
            start: start,
            text: text,
        }
    }
}

antlr4_runtime::__antlr4_rust_context_accessors! {
    DateTimeContext {
        token offset_date_time_token: optional(26),
        token local_date_time_token: optional(27),
        token local_date_token: optional(28),
        token local_time_token: optional(29),
    }
}

antlr4_runtime::__antlr4_rust_context! {
    pub struct ArrayContext {
        rule_index: 15,
        context_kind: any,
        attributes: {
        },
        methods: {
            rule_node: rule_node,
            child_count: child_count,
            direct_terminals: direct_terminals,
            start: start,
            text: text,
        }
    }
}

antlr4_runtime::__antlr4_rust_context_accessors! {
    ArrayContext {
        rule array_values: optional(ArrayValuesContext[16]),
        rule comment_or_nl: required(CommentOrNlContext[17], "comment_or_nl"),
        token l_bracket_token: required(4, "L_BRACKET"),
        token r_bracket_token: required(6, "R_BRACKET"),
    }
}

antlr4_runtime::__antlr4_rust_context! {
    pub struct ArrayValuesContext {
        rule_index: 16,
        context_kind: any,
        attributes: {
        },
        methods: {
            rule_node: rule_node,
            child_count: child_count,
            direct_terminals: direct_terminals,
            start: start,
            text: text,
        }
    }
}

antlr4_runtime::__antlr4_rust_context_accessors! {
    ArrayValuesContext {
        rule value: required(ValueContext[9], "value"),
        rule array_values: optional(ArrayValuesContext[16]),
        rule comment_or_nl_children: many(CommentOrNlContext[17]),
        token comma_token: optional(10),
    }
}

antlr4_runtime::__antlr4_rust_context! {
    pub struct CommentOrNlContext {
        rule_index: 17,
        context_kind: any,
        attributes: {
        },
        methods: {
            rule_node: rule_node,
            child_count: child_count,
            direct_terminals: direct_terminals,
            start: start,
            text: text,
        }
    }
}

antlr4_runtime::__antlr4_rust_context_accessors! {
    CommentOrNlContext {
        token nl_tokens: many(2),
        token comment_tokens: many(3),
    }
}

antlr4_runtime::__antlr4_rust_context! {
    pub struct TableContext {
        rule_index: 18,
        context_kind: any,
        attributes: {
        },
        methods: {
            rule_node: rule_node,
            child_count: child_count,
            direct_terminals: direct_terminals,
            start: start,
            text: text,
        }
    }
}

antlr4_runtime::__antlr4_rust_context_accessors! {
    TableContext {
        rule standard_table: optional(StandardTableContext[19]),
        rule array_table: optional(ArrayTableContext[23]),
    }
}

antlr4_runtime::__antlr4_rust_context! {
    pub struct StandardTableContext {
        rule_index: 19,
        context_kind: any,
        attributes: {
        },
        methods: {
            rule_node: rule_node,
            child_count: child_count,
            direct_terminals: direct_terminals,
            start: start,
            text: text,
        }
    }
}

antlr4_runtime::__antlr4_rust_context_accessors! {
    StandardTableContext {
        rule key: required(KeyContext[4], "key"),
        token l_bracket_token: required(4, "L_BRACKET"),
        token r_bracket_token: required(6, "R_BRACKET"),
    }
}

antlr4_runtime::__antlr4_rust_context! {
    pub struct InlineTableContext {
        rule_index: 20,
        context_kind: any,
        attributes: {
        },
        methods: {
            rule_node: rule_node,
            child_count: child_count,
            direct_terminals: direct_terminals,
            start: start,
            text: text,
        }
    }
}

antlr4_runtime::__antlr4_rust_context_accessors! {
    InlineTableContext {
        rule comment_or_nl_children: many(CommentOrNlContext[17]),
        rule inline_table_keyvals: required(InlineTableKeyvalsContext[21], "inline_table_keyvals"),
        token l_brace_token: required(15, "L_BRACE"),
        token r_brace_token: required(31, "R_BRACE"),
    }
}

antlr4_runtime::__antlr4_rust_context! {
    pub struct InlineTableKeyvalsContext {
        rule_index: 21,
        context_kind: any,
        attributes: {
        },
        methods: {
            rule_node: rule_node,
            child_count: child_count,
            direct_terminals: direct_terminals,
            start: start,
            text: text,
        }
    }
}

antlr4_runtime::__antlr4_rust_context_accessors! {
    InlineTableKeyvalsContext {
        rule inline_table_keyvals_non_empty: optional(InlineTableKeyvalsNonEmptyContext[22]),
    }
}

antlr4_runtime::__antlr4_rust_context! {
    pub struct InlineTableKeyvalsNonEmptyContext {
        rule_index: 22,
        context_kind: any,
        attributes: {
        },
        methods: {
            rule_node: rule_node,
            child_count: child_count,
            direct_terminals: direct_terminals,
            start: start,
            text: text,
        }
    }
}

antlr4_runtime::__antlr4_rust_context_accessors! {
    InlineTableKeyvalsNonEmptyContext {
        rule key: required(KeyContext[4], "key"),
        rule value: required(ValueContext[9], "value"),
        rule comment_or_nl_children: many(CommentOrNlContext[17]),
        rule inline_table_keyvals_non_empty: optional(InlineTableKeyvalsNonEmptyContext[22]),
        token equals_token: required(8, "EQUALS"),
        token comma_token: optional(10),
    }
}

antlr4_runtime::__antlr4_rust_context! {
    pub struct ArrayTableContext {
        rule_index: 23,
        context_kind: any,
        attributes: {
        },
        methods: {
            rule_node: rule_node,
            child_count: child_count,
            direct_terminals: direct_terminals,
            start: start,
            text: text,
        }
    }
}

antlr4_runtime::__antlr4_rust_context_accessors! {
    ArrayTableContext {
        rule key: required(KeyContext[4], "key"),
        token double_l_bracket_token: required(5, "DOUBLE_L_BRACKET"),
        token double_r_bracket_token: required(7, "DOUBLE_R_BRACKET"),
    }
}

/// Checks generated required-child invariants without changing the
/// recovery-oriented tree's type.
///
/// Strict parsing calls this after proving that lexer and parser syntax-error
/// counts are both zero. It is public so structural runtime/codegen invariant
/// failures can be diagnosed independently.
pub fn validate_tree_structure(
    parsed: &antlr4_runtime::ParsedFile,
) -> Result<(), TomlValidationError> {
    let tree = parsed.tree();
    if tree.as_rule().is_none() {
        return Err(TomlValidationError::InvalidRoot);
    }
    for node in tree.descendants() {
        match node.kind() {
            antlr4_runtime::NodeKind::Terminal => {}
            antlr4_runtime::NodeKind::Error => {
                let symbol = node
                    .as_error()
                    .expect("error node kind checked")
                    .symbol();
                return Err(TomlValidationError::RecoveredErrorNode {
                    line: symbol.line(),
                    column: symbol.column(),
                    text: symbol.text_or_empty().to_owned(),
                });
            }
            antlr4_runtime::NodeKind::Rule => {
                let context = node.as_rule().expect("rule node kind checked");
                match __context_kind(context) {
                0 => {
                    let context = DocumentContext::__from_listener_node(context, None);
        {
            let actual = context.expression_children().count();
            if actual < 1 {
                return Err(TomlValidationError::InvalidChildCount {
                    context: "DocumentContext",
                    child: "expression",
                    minimum: 1,
                    actual,
                });
            }
        }
        let _ = context.eof_token().map_err(TomlValidationError::MissingChild)?;
                },
                1 => {
                    let context = ExpressionContext::__from_listener_node(context, None);
        let _ = context.comment().map_err(TomlValidationError::MissingChild)?;
                },
                2 => {
                },
                3 => {
                    let context = KeyValueContext::__from_listener_node(context, None);
        let _ = context.key().map_err(TomlValidationError::MissingChild)?;
        let _ = context.value().map_err(TomlValidationError::MissingChild)?;
        let _ = context.equals_token().map_err(TomlValidationError::MissingChild)?;
                },
                4 => {
                },
                5 => {
                },
                6 => {
                    let context = UnquotedKeyContext::__from_listener_node(context, None);
        let _ = context.unquoted_key_token().map_err(TomlValidationError::MissingChild)?;
                },
                7 => {
                },
                8 => {
                    let context = DottedKeyContext::__from_listener_node(context, None);
        {
            let actual = context.simple_key_children().count();
            if actual < 2 {
                return Err(TomlValidationError::InvalidChildCount {
                    context: "DottedKeyContext",
                    child: "simple_key",
                    minimum: 2,
                    actual,
                });
            }
        }
        {
            let actual = context.dot_tokens().count();
            if actual < 1 {
                return Err(TomlValidationError::InvalidChildCount {
                    context: "DottedKeyContext",
                    child: "DOT",
                    minimum: 1,
                    actual,
                });
            }
        }
                },
                9 => {
                },
                10 => {
                },
                11 => {
                },
                12 => {
                },
                13 => {
                    let context = BoolContext::__from_listener_node(context, None);
        let _ = context.boolean_token().map_err(TomlValidationError::MissingChild)?;
                },
                14 => {
                },
                15 => {
                    let context = ArrayContext::__from_listener_node(context, None);
        let _ = context.comment_or_nl().map_err(TomlValidationError::MissingChild)?;
        let _ = context.l_bracket_token().map_err(TomlValidationError::MissingChild)?;
        let _ = context.r_bracket_token().map_err(TomlValidationError::MissingChild)?;
                },
                16 => {
                    let context = ArrayValuesContext::__from_listener_node(context, None);
        let _ = context.value().map_err(TomlValidationError::MissingChild)?;
        {
            let actual = context.comment_or_nl_children().count();
            if actual < 2 {
                return Err(TomlValidationError::InvalidChildCount {
                    context: "ArrayValuesContext",
                    child: "comment_or_nl",
                    minimum: 2,
                    actual,
                });
            }
        }
                },
                17 => {
                },
                18 => {
                },
                19 => {
                    let context = StandardTableContext::__from_listener_node(context, None);
        let _ = context.key().map_err(TomlValidationError::MissingChild)?;
        let _ = context.l_bracket_token().map_err(TomlValidationError::MissingChild)?;
        let _ = context.r_bracket_token().map_err(TomlValidationError::MissingChild)?;
                },
                20 => {
                    let context = InlineTableContext::__from_listener_node(context, None);
        {
            let actual = context.comment_or_nl_children().count();
            if actual < 2 {
                return Err(TomlValidationError::InvalidChildCount {
                    context: "InlineTableContext",
                    child: "comment_or_nl",
                    minimum: 2,
                    actual,
                });
            }
        }
        let _ = context.inline_table_keyvals().map_err(TomlValidationError::MissingChild)?;
        let _ = context.l_brace_token().map_err(TomlValidationError::MissingChild)?;
        let _ = context.r_brace_token().map_err(TomlValidationError::MissingChild)?;
                },
                21 => {
                },
                22 => {
                    let context = InlineTableKeyvalsNonEmptyContext::__from_listener_node(context, None);
        let _ = context.key().map_err(TomlValidationError::MissingChild)?;
        let _ = context.value().map_err(TomlValidationError::MissingChild)?;
        {
            let actual = context.comment_or_nl_children().count();
            if actual < 1 {
                return Err(TomlValidationError::InvalidChildCount {
                    context: "InlineTableKeyvalsNonEmptyContext",
                    child: "comment_or_nl",
                    minimum: 1,
                    actual,
                });
            }
        }
        let _ = context.equals_token().map_err(TomlValidationError::MissingChild)?;
                },
                23 => {
                    let context = ArrayTableContext::__from_listener_node(context, None);
        let _ = context.key().map_err(TomlValidationError::MissingChild)?;
        let _ = context.double_l_bracket_token().map_err(TomlValidationError::MissingChild)?;
        let _ = context.double_r_bracket_token().map_err(TomlValidationError::MissingChild)?;
                },
                    _ => {
                        return Err(TomlValidationError::UnknownRule {
                            rule_index: context.rule_index(),
                        });
                    }
                }
            }
        }
    }
    Ok(())
}

#[allow(dead_code, unused_variables)]
pub trait TomlListener<E = std::convert::Infallible> {
    fn walk(&mut self, tree: antlr4_runtime::Node<'_>) -> Result<(), E>
    where
        Self: Sized,
    {
        TomlTreeWalker::walk(self, tree)
    }

    fn enter_every_rule(&mut self, _ctx: RuleNodeView<'_>) -> Result<(), E> { Ok(()) }
    fn exit_every_rule(&mut self, _ctx: RuleNodeView<'_>) -> Result<(), E> { Ok(()) }

    fn enter_document(&mut self, _ctx: &DocumentContext) -> Result<(), E> { Ok(()) }
    fn exit_document(&mut self, _ctx: &DocumentContext) -> Result<(), E> { Ok(()) }
    fn enter_expression(&mut self, _ctx: &ExpressionContext) -> Result<(), E> { Ok(()) }
    fn exit_expression(&mut self, _ctx: &ExpressionContext) -> Result<(), E> { Ok(()) }
    fn enter_comment(&mut self, _ctx: &CommentContext) -> Result<(), E> { Ok(()) }
    fn exit_comment(&mut self, _ctx: &CommentContext) -> Result<(), E> { Ok(()) }
    fn enter_key_value(&mut self, _ctx: &KeyValueContext) -> Result<(), E> { Ok(()) }
    fn exit_key_value(&mut self, _ctx: &KeyValueContext) -> Result<(), E> { Ok(()) }
    fn enter_key(&mut self, _ctx: &KeyContext) -> Result<(), E> { Ok(()) }
    fn exit_key(&mut self, _ctx: &KeyContext) -> Result<(), E> { Ok(()) }
    fn enter_simple_key(&mut self, _ctx: &SimpleKeyContext) -> Result<(), E> { Ok(()) }
    fn exit_simple_key(&mut self, _ctx: &SimpleKeyContext) -> Result<(), E> { Ok(()) }
    fn enter_unquoted_key(&mut self, _ctx: &UnquotedKeyContext) -> Result<(), E> { Ok(()) }
    fn exit_unquoted_key(&mut self, _ctx: &UnquotedKeyContext) -> Result<(), E> { Ok(()) }
    fn enter_quoted_key(&mut self, _ctx: &QuotedKeyContext) -> Result<(), E> { Ok(()) }
    fn exit_quoted_key(&mut self, _ctx: &QuotedKeyContext) -> Result<(), E> { Ok(()) }
    fn enter_dotted_key(&mut self, _ctx: &DottedKeyContext) -> Result<(), E> { Ok(()) }
    fn exit_dotted_key(&mut self, _ctx: &DottedKeyContext) -> Result<(), E> { Ok(()) }
    fn enter_value(&mut self, _ctx: &ValueContext) -> Result<(), E> { Ok(()) }
    fn exit_value(&mut self, _ctx: &ValueContext) -> Result<(), E> { Ok(()) }
    fn enter_string(&mut self, _ctx: &StringContext) -> Result<(), E> { Ok(()) }
    fn exit_string(&mut self, _ctx: &StringContext) -> Result<(), E> { Ok(()) }
    fn enter_integer(&mut self, _ctx: &IntegerContext) -> Result<(), E> { Ok(()) }
    fn exit_integer(&mut self, _ctx: &IntegerContext) -> Result<(), E> { Ok(()) }
    fn enter_floating_point(&mut self, _ctx: &FloatingPointContext) -> Result<(), E> { Ok(()) }
    fn exit_floating_point(&mut self, _ctx: &FloatingPointContext) -> Result<(), E> { Ok(()) }
    fn enter_bool(&mut self, _ctx: &BoolContext) -> Result<(), E> { Ok(()) }
    fn exit_bool(&mut self, _ctx: &BoolContext) -> Result<(), E> { Ok(()) }
    fn enter_date_time(&mut self, _ctx: &DateTimeContext) -> Result<(), E> { Ok(()) }
    fn exit_date_time(&mut self, _ctx: &DateTimeContext) -> Result<(), E> { Ok(()) }
    fn enter_array(&mut self, _ctx: &ArrayContext) -> Result<(), E> { Ok(()) }
    fn exit_array(&mut self, _ctx: &ArrayContext) -> Result<(), E> { Ok(()) }
    fn enter_array_values(&mut self, _ctx: &ArrayValuesContext) -> Result<(), E> { Ok(()) }
    fn exit_array_values(&mut self, _ctx: &ArrayValuesContext) -> Result<(), E> { Ok(()) }
    fn enter_comment_or_nl(&mut self, _ctx: &CommentOrNlContext) -> Result<(), E> { Ok(()) }
    fn exit_comment_or_nl(&mut self, _ctx: &CommentOrNlContext) -> Result<(), E> { Ok(()) }
    fn enter_table(&mut self, _ctx: &TableContext) -> Result<(), E> { Ok(()) }
    fn exit_table(&mut self, _ctx: &TableContext) -> Result<(), E> { Ok(()) }
    fn enter_standard_table(&mut self, _ctx: &StandardTableContext) -> Result<(), E> { Ok(()) }
    fn exit_standard_table(&mut self, _ctx: &StandardTableContext) -> Result<(), E> { Ok(()) }
    fn enter_inline_table(&mut self, _ctx: &InlineTableContext) -> Result<(), E> { Ok(()) }
    fn exit_inline_table(&mut self, _ctx: &InlineTableContext) -> Result<(), E> { Ok(()) }
    fn enter_inline_table_keyvals(&mut self, _ctx: &InlineTableKeyvalsContext) -> Result<(), E> { Ok(()) }
    fn exit_inline_table_keyvals(&mut self, _ctx: &InlineTableKeyvalsContext) -> Result<(), E> { Ok(()) }
    fn enter_inline_table_keyvals_non_empty(&mut self, _ctx: &InlineTableKeyvalsNonEmptyContext) -> Result<(), E> { Ok(()) }
    fn exit_inline_table_keyvals_non_empty(&mut self, _ctx: &InlineTableKeyvalsNonEmptyContext) -> Result<(), E> { Ok(()) }
    fn enter_array_table(&mut self, _ctx: &ArrayTableContext) -> Result<(), E> { Ok(()) }
    fn exit_array_table(&mut self, _ctx: &ArrayTableContext) -> Result<(), E> { Ok(()) }
    fn visit_terminal(&mut self, _node: &TerminalNode) -> Result<(), E> { Ok(()) }
    fn visit_error_node(&mut self, _node: &ErrorNode) -> Result<(), E> { Ok(()) }
    fn output(&mut self) -> std::io::Stdout { std::io::stdout() }
}

#[allow(dead_code)]
pub struct TomlTreeWalker;

#[allow(dead_code)]
impl TomlTreeWalker {
    pub fn walk<E, T: TomlListener<E>>(
        listener: &mut T,
        tree: antlr4_runtime::Node<'_>,
    ) -> Result<(), E> {
        Self::__walk(listener, tree, None)
    }

    pub fn walk_with_invocation_states<E, T: TomlListener<E>>(
        listener: &mut T,
        tree: antlr4_runtime::Node<'_>,
        parent_invocation_states: Vec<isize>,
    ) -> Result<(), E> {
        Self::__walk(listener, tree, Some(parent_invocation_states))
    }

    fn __walk<E, T: TomlListener<E>>(
        listener: &mut T,
        tree: antlr4_runtime::Node<'_>,
        mut invocation_states: Option<Vec<isize>>,
    ) -> Result<(), E> {
        enum Event<'tree> {
            Enter(antlr4_runtime::Node<'tree>),
            Exit(RuleNodeView<'tree>),
        }

        let mut stack = vec![Event::Enter(tree)];
        while let Some(event) = stack.pop() {
            match event {
                Event::Enter(node) => match node.kind() {
                    antlr4_runtime::NodeKind::Rule => {
                        let context = node.as_rule().expect("rule node kind checked");
                        if let Some(states) = &mut invocation_states {
                            states.insert(0, context.invoking_state());
                        }
                        listener.enter_every_rule(context)?;
                        match __context_kind(context) {
                        0 => listener.enter_document(&DocumentContext::__from_listener_node(context, invocation_states.as_deref()))?,
                        1 => listener.enter_expression(&ExpressionContext::__from_listener_node(context, invocation_states.as_deref()))?,
                        2 => listener.enter_comment(&CommentContext::__from_listener_node(context, invocation_states.as_deref()))?,
                        3 => listener.enter_key_value(&KeyValueContext::__from_listener_node(context, invocation_states.as_deref()))?,
                        4 => listener.enter_key(&KeyContext::__from_listener_node(context, invocation_states.as_deref()))?,
                        5 => listener.enter_simple_key(&SimpleKeyContext::__from_listener_node(context, invocation_states.as_deref()))?,
                        6 => listener.enter_unquoted_key(&UnquotedKeyContext::__from_listener_node(context, invocation_states.as_deref()))?,
                        7 => listener.enter_quoted_key(&QuotedKeyContext::__from_listener_node(context, invocation_states.as_deref()))?,
                        8 => listener.enter_dotted_key(&DottedKeyContext::__from_listener_node(context, invocation_states.as_deref()))?,
                        9 => listener.enter_value(&ValueContext::__from_listener_node(context, invocation_states.as_deref()))?,
                        10 => listener.enter_string(&StringContext::__from_listener_node(context, invocation_states.as_deref()))?,
                        11 => listener.enter_integer(&IntegerContext::__from_listener_node(context, invocation_states.as_deref()))?,
                        12 => listener.enter_floating_point(&FloatingPointContext::__from_listener_node(context, invocation_states.as_deref()))?,
                        13 => listener.enter_bool(&BoolContext::__from_listener_node(context, invocation_states.as_deref()))?,
                        14 => listener.enter_date_time(&DateTimeContext::__from_listener_node(context, invocation_states.as_deref()))?,
                        15 => listener.enter_array(&ArrayContext::__from_listener_node(context, invocation_states.as_deref()))?,
                        16 => listener.enter_array_values(&ArrayValuesContext::__from_listener_node(context, invocation_states.as_deref()))?,
                        17 => listener.enter_comment_or_nl(&CommentOrNlContext::__from_listener_node(context, invocation_states.as_deref()))?,
                        18 => listener.enter_table(&TableContext::__from_listener_node(context, invocation_states.as_deref()))?,
                        19 => listener.enter_standard_table(&StandardTableContext::__from_listener_node(context, invocation_states.as_deref()))?,
                        20 => listener.enter_inline_table(&InlineTableContext::__from_listener_node(context, invocation_states.as_deref()))?,
                        21 => listener.enter_inline_table_keyvals(&InlineTableKeyvalsContext::__from_listener_node(context, invocation_states.as_deref()))?,
                        22 => listener.enter_inline_table_keyvals_non_empty(&InlineTableKeyvalsNonEmptyContext::__from_listener_node(context, invocation_states.as_deref()))?,
                        23 => listener.enter_array_table(&ArrayTableContext::__from_listener_node(context, invocation_states.as_deref()))?,
                            _ => {}
                        }
                        stack.push(Event::Exit(context));
                        stack.extend(context.children().rev().map(Event::Enter));
                    }
                    antlr4_runtime::NodeKind::Terminal => {
                        listener.visit_terminal(&TerminalNode::new(
                            node.as_terminal().expect("terminal node kind checked"),
                        ))?;
                    }
                    antlr4_runtime::NodeKind::Error => {
                        listener.visit_error_node(&ErrorNode::new(
                            node.as_error().expect("error node kind checked"),
                        ))?;
                    }
                },
                Event::Exit(context) => {
                    match __context_kind(context) {
                    0 => listener.exit_document(&DocumentContext::__from_listener_node(context, invocation_states.as_deref()))?,
                    1 => listener.exit_expression(&ExpressionContext::__from_listener_node(context, invocation_states.as_deref()))?,
                    2 => listener.exit_comment(&CommentContext::__from_listener_node(context, invocation_states.as_deref()))?,
                    3 => listener.exit_key_value(&KeyValueContext::__from_listener_node(context, invocation_states.as_deref()))?,
                    4 => listener.exit_key(&KeyContext::__from_listener_node(context, invocation_states.as_deref()))?,
                    5 => listener.exit_simple_key(&SimpleKeyContext::__from_listener_node(context, invocation_states.as_deref()))?,
                    6 => listener.exit_unquoted_key(&UnquotedKeyContext::__from_listener_node(context, invocation_states.as_deref()))?,
                    7 => listener.exit_quoted_key(&QuotedKeyContext::__from_listener_node(context, invocation_states.as_deref()))?,
                    8 => listener.exit_dotted_key(&DottedKeyContext::__from_listener_node(context, invocation_states.as_deref()))?,
                    9 => listener.exit_value(&ValueContext::__from_listener_node(context, invocation_states.as_deref()))?,
                    10 => listener.exit_string(&StringContext::__from_listener_node(context, invocation_states.as_deref()))?,
                    11 => listener.exit_integer(&IntegerContext::__from_listener_node(context, invocation_states.as_deref()))?,
                    12 => listener.exit_floating_point(&FloatingPointContext::__from_listener_node(context, invocation_states.as_deref()))?,
                    13 => listener.exit_bool(&BoolContext::__from_listener_node(context, invocation_states.as_deref()))?,
                    14 => listener.exit_date_time(&DateTimeContext::__from_listener_node(context, invocation_states.as_deref()))?,
                    15 => listener.exit_array(&ArrayContext::__from_listener_node(context, invocation_states.as_deref()))?,
                    16 => listener.exit_array_values(&ArrayValuesContext::__from_listener_node(context, invocation_states.as_deref()))?,
                    17 => listener.exit_comment_or_nl(&CommentOrNlContext::__from_listener_node(context, invocation_states.as_deref()))?,
                    18 => listener.exit_table(&TableContext::__from_listener_node(context, invocation_states.as_deref()))?,
                    19 => listener.exit_standard_table(&StandardTableContext::__from_listener_node(context, invocation_states.as_deref()))?,
                    20 => listener.exit_inline_table(&InlineTableContext::__from_listener_node(context, invocation_states.as_deref()))?,
                    21 => listener.exit_inline_table_keyvals(&InlineTableKeyvalsContext::__from_listener_node(context, invocation_states.as_deref()))?,
                    22 => listener.exit_inline_table_keyvals_non_empty(&InlineTableKeyvalsNonEmptyContext::__from_listener_node(context, invocation_states.as_deref()))?,
                    23 => listener.exit_array_table(&ArrayTableContext::__from_listener_node(context, invocation_states.as_deref()))?,
                        _ => {}
                    }
                    listener.exit_every_rule(context)?;
                    if let Some(states) = &mut invocation_states {
                        states.remove(0);
                    }
                }
            }
        }
        Ok(())
    }
}

pub type ParseTreeWalker = TomlTreeWalker;

#[allow(dead_code, unused_variables)]
pub trait TomlValidatedListener<E = std::convert::Infallible> {
    fn walk(&mut self, tree: ValidatedRuleNode<'_>) -> Result<(), E>
    where
        Self: Sized,
    {
        TomlValidatedTreeWalker::walk(self, tree)
    }

    fn enter_every_rule(&mut self, _ctx: ValidatedRuleNode<'_>) -> Result<(), E> { Ok(()) }
    fn exit_every_rule(&mut self, _ctx: ValidatedRuleNode<'_>) -> Result<(), E> { Ok(()) }

    fn enter_document(&mut self, _ctx: &DocumentContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn exit_document(&mut self, _ctx: &DocumentContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn enter_expression(&mut self, _ctx: &ExpressionContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn exit_expression(&mut self, _ctx: &ExpressionContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn enter_comment(&mut self, _ctx: &CommentContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn exit_comment(&mut self, _ctx: &CommentContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn enter_key_value(&mut self, _ctx: &KeyValueContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn exit_key_value(&mut self, _ctx: &KeyValueContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn enter_key(&mut self, _ctx: &KeyContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn exit_key(&mut self, _ctx: &KeyContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn enter_simple_key(&mut self, _ctx: &SimpleKeyContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn exit_simple_key(&mut self, _ctx: &SimpleKeyContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn enter_unquoted_key(&mut self, _ctx: &UnquotedKeyContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn exit_unquoted_key(&mut self, _ctx: &UnquotedKeyContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn enter_quoted_key(&mut self, _ctx: &QuotedKeyContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn exit_quoted_key(&mut self, _ctx: &QuotedKeyContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn enter_dotted_key(&mut self, _ctx: &DottedKeyContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn exit_dotted_key(&mut self, _ctx: &DottedKeyContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn enter_value(&mut self, _ctx: &ValueContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn exit_value(&mut self, _ctx: &ValueContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn enter_string(&mut self, _ctx: &StringContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn exit_string(&mut self, _ctx: &StringContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn enter_integer(&mut self, _ctx: &IntegerContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn exit_integer(&mut self, _ctx: &IntegerContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn enter_floating_point(&mut self, _ctx: &FloatingPointContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn exit_floating_point(&mut self, _ctx: &FloatingPointContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn enter_bool(&mut self, _ctx: &BoolContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn exit_bool(&mut self, _ctx: &BoolContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn enter_date_time(&mut self, _ctx: &DateTimeContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn exit_date_time(&mut self, _ctx: &DateTimeContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn enter_array(&mut self, _ctx: &ArrayContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn exit_array(&mut self, _ctx: &ArrayContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn enter_array_values(&mut self, _ctx: &ArrayValuesContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn exit_array_values(&mut self, _ctx: &ArrayValuesContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn enter_comment_or_nl(&mut self, _ctx: &CommentOrNlContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn exit_comment_or_nl(&mut self, _ctx: &CommentOrNlContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn enter_table(&mut self, _ctx: &TableContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn exit_table(&mut self, _ctx: &TableContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn enter_standard_table(&mut self, _ctx: &StandardTableContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn exit_standard_table(&mut self, _ctx: &StandardTableContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn enter_inline_table(&mut self, _ctx: &InlineTableContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn exit_inline_table(&mut self, _ctx: &InlineTableContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn enter_inline_table_keyvals(&mut self, _ctx: &InlineTableKeyvalsContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn exit_inline_table_keyvals(&mut self, _ctx: &InlineTableKeyvalsContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn enter_inline_table_keyvals_non_empty(&mut self, _ctx: &InlineTableKeyvalsNonEmptyContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn exit_inline_table_keyvals_non_empty(&mut self, _ctx: &InlineTableKeyvalsNonEmptyContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn enter_array_table(&mut self, _ctx: &ArrayTableContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn exit_array_table(&mut self, _ctx: &ArrayTableContext<ValidatedTreeContext>) -> Result<(), E> { Ok(()) }
    fn visit_terminal(&mut self, _node: &TerminalNode) -> Result<(), E> { Ok(()) }
    fn output(&mut self) -> std::io::Stdout { std::io::stdout() }
}

#[allow(dead_code)]
pub struct TomlValidatedTreeWalker;

#[allow(dead_code)]
impl TomlValidatedTreeWalker {
    pub fn walk<E, T: TomlValidatedListener<E>>(
        listener: &mut T,
        tree: ValidatedRuleNode<'_>,
    ) -> Result<(), E> {
        Self::__walk(listener, tree.node(), None)
    }

    pub fn walk_with_invocation_states<E, T: TomlValidatedListener<E>>(
        listener: &mut T,
        tree: ValidatedRuleNode<'_>,
        parent_invocation_states: Vec<isize>,
    ) -> Result<(), E> {
        Self::__walk(listener, tree.node(), Some(parent_invocation_states))
    }

    fn __walk<E, T: TomlValidatedListener<E>>(
        listener: &mut T,
        tree: antlr4_runtime::Node<'_>,
        mut invocation_states: Option<Vec<isize>>,
    ) -> Result<(), E> {
        enum Event<'tree> {
            Enter(antlr4_runtime::Node<'tree>),
            Exit(RuleNodeView<'tree>),
        }

        let mut stack = vec![Event::Enter(tree)];
        while let Some(event) = stack.pop() {
            match event {
                Event::Enter(node) => match node.kind() {
                    antlr4_runtime::NodeKind::Rule => {
                        let context = node.as_rule().expect("rule node kind checked");
                        if let Some(states) = &mut invocation_states {
                            states.insert(0, context.invoking_state());
                        }
                        listener.enter_every_rule(ValidatedRuleNode { __node: context })?;
                        match __context_kind(context) {
                        0 => listener.enter_document(&DocumentContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                        1 => listener.enter_expression(&ExpressionContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                        2 => listener.enter_comment(&CommentContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                        3 => listener.enter_key_value(&KeyValueContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                        4 => listener.enter_key(&KeyContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                        5 => listener.enter_simple_key(&SimpleKeyContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                        6 => listener.enter_unquoted_key(&UnquotedKeyContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                        7 => listener.enter_quoted_key(&QuotedKeyContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                        8 => listener.enter_dotted_key(&DottedKeyContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                        9 => listener.enter_value(&ValueContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                        10 => listener.enter_string(&StringContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                        11 => listener.enter_integer(&IntegerContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                        12 => listener.enter_floating_point(&FloatingPointContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                        13 => listener.enter_bool(&BoolContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                        14 => listener.enter_date_time(&DateTimeContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                        15 => listener.enter_array(&ArrayContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                        16 => listener.enter_array_values(&ArrayValuesContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                        17 => listener.enter_comment_or_nl(&CommentOrNlContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                        18 => listener.enter_table(&TableContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                        19 => listener.enter_standard_table(&StandardTableContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                        20 => listener.enter_inline_table(&InlineTableContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                        21 => listener.enter_inline_table_keyvals(&InlineTableKeyvalsContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                        22 => listener.enter_inline_table_keyvals_non_empty(&InlineTableKeyvalsNonEmptyContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                        23 => listener.enter_array_table(&ArrayTableContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                            _ => {}
                        }
                        stack.push(Event::Exit(context));
                        stack.extend(context.children().rev().map(Event::Enter));
                    }
                    antlr4_runtime::NodeKind::Terminal => {
                        listener.visit_terminal(&TerminalNode::new(
                            node.as_terminal().expect("terminal node kind checked"),
                        ))?;
                    }
                    antlr4_runtime::NodeKind::Error => {
                        unreachable!("validated parse tree contains an error node")
                    }
                },
                Event::Exit(context) => {
                    match __context_kind(context) {
                    0 => listener.exit_document(&DocumentContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                    1 => listener.exit_expression(&ExpressionContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                    2 => listener.exit_comment(&CommentContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                    3 => listener.exit_key_value(&KeyValueContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                    4 => listener.exit_key(&KeyContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                    5 => listener.exit_simple_key(&SimpleKeyContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                    6 => listener.exit_unquoted_key(&UnquotedKeyContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                    7 => listener.exit_quoted_key(&QuotedKeyContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                    8 => listener.exit_dotted_key(&DottedKeyContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                    9 => listener.exit_value(&ValueContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                    10 => listener.exit_string(&StringContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                    11 => listener.exit_integer(&IntegerContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                    12 => listener.exit_floating_point(&FloatingPointContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                    13 => listener.exit_bool(&BoolContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                    14 => listener.exit_date_time(&DateTimeContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                    15 => listener.exit_array(&ArrayContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                    16 => listener.exit_array_values(&ArrayValuesContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                    17 => listener.exit_comment_or_nl(&CommentOrNlContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                    18 => listener.exit_table(&TableContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                    19 => listener.exit_standard_table(&StandardTableContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                    20 => listener.exit_inline_table(&InlineTableContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                    21 => listener.exit_inline_table_keyvals(&InlineTableKeyvalsContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                    22 => listener.exit_inline_table_keyvals_non_empty(&InlineTableKeyvalsNonEmptyContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                    23 => listener.exit_array_table(&ArrayTableContext::<ValidatedTreeContext>::__from_validated_listener_node(context, invocation_states.as_deref()))?,
                        _ => {}
                    }
                    listener.exit_every_rule(ValidatedRuleNode { __node: context })?;
                    if let Some(states) = &mut invocation_states {
                        states.remove(0);
                    }
                }
            }
        }
        Ok(())
    }
}

pub type ValidatedParseTreeWalker = TomlValidatedTreeWalker;



static PARSER_ATN_DATA: &[u32] = &[1346458702, 2, 16909060, 29, 32, 176, 218, 5, 6, 16, 24, 29, 1232, 1261, 1090, 2351, 25, 2376, 12, 2408, 16, 2424, 24, 2448, 24, 2472, 10, 2388, 20, 2, 0, 8, 0, 1, 4294967295, 4294967295, 7, 0, 16, 1, 0, 4294967295, 4294967295, 2, 1, 8, 1, 1, 4294967295, 4294967295, 7, 1, 24, 2, 2, 4294967295, 4294967295, 2, 2, 8, 4, 1, 4294967295, 4294967295, 7, 2, 24, 5, 3, 4294967295, 4294967295, 2, 3, 8, 8, 1, 4294967295, 4294967295, 7, 3, 24, 9, 1, 4294967295, 4294967295, 2, 4, 8, 10, 1, 4294967295, 4294967295, 7, 4, 24, 11, 4, 4294967295, 4294967295, 2, 5, 8, 15, 1, 4294967295, 4294967295, 7, 5, 24, 16, 3, 4294967295, 4294967295, 2, 6, 8, 19, 1, 4294967295, 4294967295, 7, 6, 24, 20, 1, 4294967295, 4294967295, 2, 7, 8, 21, 1, 4294967295, 4294967295, 7, 7, 24, 22, 1, 4294967295, 4294967295, 2, 8, 8, 23, 1, 4294967295, 4294967295, 7, 8, 24, 24, 1, 4294967295, 4294967295, 2, 9, 8, 25, 1, 4294967295, 4294967295, 7, 9, 24, 26, 4, 4294967295, 4294967295, 2, 10, 8, 30, 1, 4294967295, 4294967295, 7, 10, 24, 31, 1, 4294967295, 4294967295, 2, 11, 8, 32, 1, 4294967295, 4294967295, 7, 11, 24, 33, 1, 4294967295, 4294967295, 2, 12, 8, 34, 1, 4294967295, 4294967295, 7, 12, 24, 35, 1, 4294967295, 4294967295, 2, 13, 8, 36, 1, 4294967295, 4294967295, 7, 13, 24, 37, 1, 4294967295, 4294967295, 2, 14, 8, 38, 1, 4294967295, 4294967295, 7, 14, 24, 39, 1, 4294967295, 4294967295, 2, 15, 8, 40, 1, 4294967295, 4294967295, 7, 15, 24, 41, 1, 4294967295, 4294967295, 2, 16, 8, 42, 1, 4294967295, 4294967295, 7, 16, 24, 43, 2, 4294967295, 4294967295, 2, 17, 8, 45, 1, 4294967295, 4294967295, 7, 17, 24, 46, 10, 4294967295, 4294967295, 2, 18, 8, 56, 1, 4294967295, 4294967295, 7, 18, 24, 57, 1, 4294967295, 4294967295, 2, 19, 8, 58, 1, 4294967295, 4294967295, 7, 19, 24, 59, 1, 4294967295, 4294967295, 2, 20, 8, 60, 1, 4294967295, 4294967295, 7, 20, 24, 61, 1, 4294967295, 4294967295, 2, 21, 8, 62, 1, 4294967295, 4294967295, 7, 21, 24, 63, 1, 4294967295, 4294967295, 2, 22, 8, 64, 1, 4294967295, 4294967295, 7, 22, 24, 65, 2, 4294967295, 4294967295, 2, 23, 8, 67, 1, 4294967295, 4294967295, 7, 23, 24, 68, 1, 4294967295, 4294967295, 1, 0, 8, 69, 1, 4294967295, 4294967295, 1, 0, 32, 70, 1, 4294967295, 4294967295, 1, 0, 8, 71, 1, 4294967295, 4294967295, 5, 0, 8, 72, 1, 52, 4294967295, 8, 0, 8, 73, 1, 4294967295, 4294967295, 10, 0, 8, 74, 2, 4294967295, 4294967295, 12, 0, 8, 76, 1, 4294967295, 55, 9, 0, 8, 77, 1, 4294967295, 4294967295, 1, 0, 32, 78, 1, 4294967295, 4294967295, 1, 0, 8, 79, 1, 4294967295, 4294967295, 1, 1, 8, 80, 1, 4294967295, 4294967295, 1, 1, 8, 81, 1, 4294967295, 4294967295, 1, 1, 8, 82, 1, 4294967295, 4294967295, 1, 1, 8, 83, 1, 4294967295, 4294967295, 1, 1, 8, 84, 1, 4294967295, 4294967295, 1, 1, 8, 85, 1, 4294967295, 4294967295, 1, 1, 8, 86, 1, 4294967295, 4294967295, 3, 1, 8, 87, 3, 66, 4294967295, 8, 1, 8, 90, 1, 4294967295, 4294967295, 1, 2, 32, 91, 1, 4294967295, 4294967295, 3, 2, 8, 92, 2, 69, 4294967295, 8, 2, 8, 94, 1, 4294967295, 4294967295, 1, 3, 8, 95, 1, 4294967295, 4294967295, 1, 3, 32, 96, 1, 4294967295, 4294967295, 1, 3, 8, 97, 1, 4294967295, 4294967295, 1, 3, 8, 98, 1, 4294967295, 4294967295, 1, 4, 8, 99, 1, 4294967295, 4294967295, 1, 4, 8, 100, 1, 4294967295, 4294967295, 3, 4, 8, 101, 2, 77, 4294967295, 8, 4, 8, 103, 1, 4294967295, 4294967295, 1, 5, 8, 104, 1, 4294967295, 4294967295, 1, 5, 8, 105, 1, 4294967295, 4294967295, 3, 5, 8, 106, 2, 81, 4294967295, 8, 5, 8, 108, 1, 4294967295, 4294967295, 1, 6, 32, 109, 1, 4294967295, 4294967295, 1, 6, 8, 110, 1, 4294967295, 4294967295, 1, 7, 32, 111, 1, 4294967295, 4294967295, 1, 7, 8, 112, 1, 4294967295, 4294967295, 1, 8, 8, 113, 1, 4294967295, 4294967295, 1, 8, 32, 114, 1, 4294967295, 4294967295, 1, 8, 8, 115, 1, 4294967295, 4294967295, 4, 8, 8, 116, 1, 90, 4294967295, 8, 8, 8, 117, 1, 4294967295, 4294967295, 11, 8, 8, 118, 2, 4294967295, 4294967295, 12, 8, 8, 120, 1, 4294967295, 91, 1, 9, 8, 121, 1, 4294967295, 4294967295, 1, 9, 8, 122, 1, 4294967295, 4294967295, 1, 9, 8, 123, 1, 4294967295, 4294967295, 1, 9, 8, 124, 1, 4294967295, 4294967295, 1, 9, 8, 125, 1, 4294967295, 4294967295, 1, 9, 8, 126, 1, 4294967295, 4294967295, 1, 9, 8, 127, 1, 4294967295, 4294967295, 3, 9, 8, 128, 7, 101, 4294967295, 8, 9, 8, 135, 1, 4294967295, 4294967295, 1, 10, 32, 136, 1, 4294967295, 4294967295, 1, 10, 8, 137, 1, 4294967295, 4294967295, 1, 11, 32, 138, 1, 4294967295, 4294967295, 1, 11, 8, 139, 1, 4294967295, 4294967295, 1, 12, 32, 140, 1, 4294967295, 4294967295, 1, 12, 8, 141, 1, 4294967295, 4294967295, 1, 13, 32, 142, 1, 4294967295, 4294967295, 1, 13, 8, 143, 1, 4294967295, 4294967295, 1, 14, 32, 144, 1, 4294967295, 4294967295, 1, 14, 8, 145, 1, 4294967295, 4294967295, 1, 15, 32, 146, 1, 4294967295, 4294967295, 1, 15, 8, 147, 1, 4294967295, 4294967295, 3, 15, 8, 148, 2, 115, 4294967295, 8, 15, 8, 150, 1, 4294967295, 4294967295, 1, 15, 8, 151, 1, 4294967295, 4294967295, 1, 15, 32, 152, 1, 4294967295, 4294967295, 1, 15, 8, 153, 1, 4294967295, 4294967295, 1, 16, 8, 154, 1, 4294967295, 4294967295, 1, 16, 8, 155, 1, 4294967295, 4294967295, 1, 16, 8, 156, 1, 4294967295, 4294967295, 1, 16, 32, 157, 1, 4294967295, 4294967295, 1, 16, 8, 158, 1, 4294967295, 4294967295, 1, 16, 8, 159, 1, 4294967295, 4294967295, 1, 16, 8, 160, 1, 4294967295, 4294967295, 1, 16, 8, 161, 1, 4294967295, 4294967295, 1, 16, 8, 162, 1, 4294967295, 4294967295, 1, 16, 8, 163, 1, 4294967295, 4294967295, 1, 16, 32, 164, 1, 4294967295, 4294967295, 3, 16, 8, 165, 2, 131, 4294967295, 8, 16, 8, 167, 1, 4294967295, 4294967295, 3, 16, 8, 168, 2, 133, 4294967295, 8, 16, 8, 170, 1, 4294967295, 4294967295, 1, 17, 32, 171, 1, 4294967295, 4294967295, 3, 17, 8, 172, 2, 136, 4294967295, 8, 17, 8, 174, 1, 4294967295, 4294967295, 1, 17, 32, 175, 1, 4294967295, 4294967295, 5, 17, 8, 176, 1, 139, 4294967295, 8, 17, 8, 177, 1, 4294967295, 4294967295, 10, 17, 8, 178, 2, 4294967295, 4294967295, 12, 17, 8, 180, 1, 4294967295, 142, 9, 17, 8, 181, 1, 4294967295, 4294967295, 1, 18, 8, 182, 1, 4294967295, 4294967295, 1, 18, 8, 183, 1, 4294967295, 4294967295, 3, 18, 8, 184, 2, 146, 4294967295, 8, 18, 8, 186, 1, 4294967295, 4294967295, 1, 19, 32, 187, 1, 4294967295, 4294967295, 1, 19, 8, 188, 1, 4294967295, 4294967295, 1, 19, 32, 189, 1, 4294967295, 4294967295, 1, 19, 8, 190, 1, 4294967295, 4294967295, 1, 20, 32, 191, 1, 4294967295, 4294967295, 1, 20, 8, 192, 1, 4294967295, 4294967295, 1, 20, 8, 193, 1, 4294967295, 4294967295, 1, 20, 8, 194, 1, 4294967295, 4294967295, 1, 20, 32, 195, 1, 4294967295, 4294967295, 1, 20, 8, 196, 1, 4294967295, 4294967295, 1, 21, 8, 197, 1, 4294967295, 4294967295, 3, 21, 8, 198, 2, 159, 4294967295, 8, 21, 8, 200, 1, 4294967295, 4294967295, 1, 22, 8, 201, 1, 4294967295, 4294967295, 1, 22, 32, 202, 1, 4294967295, 4294967295, 1, 22, 8, 203, 1, 4294967295, 4294967295, 1, 22, 8, 204, 1, 4294967295, 4294967295, 1, 22, 32, 205, 1, 4294967295, 4294967295, 1, 22, 8, 206, 1, 4294967295, 4294967295, 1, 22, 8, 207, 1, 4294967295, 4294967295, 3, 22, 8, 208, 2, 168, 4294967295, 8, 22, 8, 210, 1, 4294967295, 4294967295, 3, 22, 8, 211, 2, 170, 4294967295, 8, 22, 8, 213, 1, 4294967295, 4294967295, 1, 23, 32, 214, 1, 4294967295, 4294967295, 1, 23, 8, 215, 1, 4294967295, 4294967295, 1, 23, 32, 216, 1, 4294967295, 4294967295, 1, 23, 8, 217, 1, 4294967295, 4294967295, 1, 23, 0, 218, 0, 4294967295, 4294967295, 1, 48, 0, 0, 0, 1, 65, 0, 0, 0, 1, 53, 0, 0, 0, 1, 52, 0, 0, 0, 1, 68, 0, 0, 0, 1, 60, 0, 0, 0, 1, 63, 0, 0, 0, 1, 66, 0, 0, 0, 1, 70, 0, 0, 0, 1, 59, 0, 0, 0, 1, 76, 0, 0, 0, 1, 71, 0, 0, 0, 1, 149, 0, 0, 0, 1, 161, 0, 0, 0, 1, 173, 0, 0, 0, 1, 80, 0, 0, 0, 1, 77, 0, 0, 0, 1, 89, 0, 0, 0, 1, 90, 0, 0, 0, 1, 82, 0, 0, 0, 1, 81, 0, 0, 0, 1, 84, 0, 0, 0, 1, 81, 0, 0, 0, 1, 86, 0, 0, 0, 1, 77, 0, 0, 0, 1, 100, 0, 0, 0, 1, 73, 0, 0, 0, 1, 121, 0, 0, 0, 1, 128, 0, 0, 0, 1, 163, 0, 0, 0, 1, 102, 0, 0, 0, 1, 101, 0, 0, 0, 1, 104, 0, 0, 0, 1, 101, 0, 0, 0, 1, 106, 0, 0, 0, 1, 101, 0, 0, 0, 1, 108, 0, 0, 0, 1, 101, 0, 0, 0, 1, 110, 0, 0, 0, 1, 101, 0, 0, 0, 1, 112, 0, 0, 0, 1, 101, 0, 0, 0, 1, 132, 0, 0, 0, 1, 115, 0, 0, 0, 1, 124, 0, 0, 0, 1, 140, 0, 0, 0, 1, 117, 0, 0, 0, 1, 120, 0, 0, 0, 1, 122, 0, 0, 0, 1, 125, 0, 0, 0, 1, 127, 0, 0, 0, 1, 130, 0, 0, 0, 1, 153, 0, 0, 0, 1, 155, 0, 0, 0, 1, 169, 0, 0, 0, 1, 167, 0, 0, 0, 1, 145, 0, 0, 0, 1, 62, 0, 0, 0, 1, 147, 0, 0, 0, 1, 146, 0, 0, 0, 1, 151, 0, 0, 0, 1, 101, 0, 0, 0, 1, 158, 0, 0, 0, 1, 154, 0, 0, 0, 1, 160, 0, 0, 0, 1, 159, 0, 0, 0, 1, 168, 0, 0, 0, 1, 171, 0, 0, 0, 1, 146, 0, 0, 0, 3, 2, 1, 53, 0, 5, 50, 2, 0, 0, 3, 2, 1, 52, 0, 1, 49, 0, 0, 0, 1, 55, 0, 0, 0, 1, 51, 0, 0, 0, 1, 54, 0, 0, 0, 1, 56, 0, 0, 0, 1, 53, 0, 0, 0, 5, 57, 4294967295, 0, 0, 1, 1, 0, 0, 0, 3, 6, 3, 59, 0, 3, 4, 2, 60, 0, 1, 66, 0, 0, 0, 3, 36, 18, 62, 0, 3, 4, 2, 63, 0, 1, 66, 0, 0, 0, 3, 4, 2, 66, 0, 1, 58, 0, 0, 0, 1, 61, 0, 0, 0, 1, 64, 0, 0, 0, 1, 3, 0, 0, 0, 5, 69, 3, 0, 0, 1, 67, 0, 0, 0, 1, 69, 0, 0, 0, 1, 5, 0, 0, 0, 3, 8, 4, 71, 0, 5, 72, 8, 0, 0, 3, 18, 9, 73, 0, 1, 7, 0, 0, 0, 3, 10, 5, 77, 0, 3, 16, 8, 77, 0, 1, 74, 0, 0, 0, 1, 75, 0, 0, 0, 1, 9, 0, 0, 0, 3, 14, 7, 81, 0, 3, 12, 6, 81, 0, 1, 78, 0, 0, 0, 1, 79, 0, 0, 0, 1, 11, 0, 0, 0, 5, 83, 13, 0, 0, 1, 13, 0, 0, 0, 7, 85, 0, 0, 0, 1, 15, 0, 0, 0, 3, 10, 5, 89, 0, 5, 88, 9, 0, 0, 3, 10, 5, 90, 0, 1, 87, 0, 0, 0, 1, 91, 0, 0, 0, 1, 89, 0, 0, 0, 1, 92, 0, 0, 0, 1, 17, 0, 0, 0, 3, 20, 10, 101, 0, 3, 22, 11, 101, 0, 3, 24, 12, 101, 0, 3, 26, 13, 101, 0, 3, 28, 14, 101, 0, 3, 30, 15, 101, 0, 3, 40, 20, 101, 0, 1, 93, 0, 0, 0, 1, 94, 0, 0, 0, 1, 95, 0, 0, 0, 1, 96, 0, 0, 0, 1, 97, 0, 0, 0, 1, 98, 0, 0, 0, 1, 99, 0, 0, 0, 1, 19, 0, 0, 0, 7, 103, 1, 0, 0, 1, 21, 0, 0, 0, 7, 105, 2, 0, 0, 1, 23, 0, 0, 0, 7, 107, 3, 0, 0, 1, 25, 0, 0, 0, 5, 109, 16, 0, 0, 1, 27, 0, 0, 0, 7, 111, 4, 0, 0, 1, 29, 0, 0, 0, 5, 114, 4, 0, 0, 3, 32, 16, 115, 0, 1, 113, 0, 0, 0, 1, 115, 0, 0, 0, 1, 116, 0, 0, 0, 3, 34, 17, 117, 0, 5, 118, 6, 0, 0, 1, 31, 0, 0, 0, 3, 34, 17, 120, 0, 3, 18, 9, 121, 0, 3, 34, 17, 122, 0, 5, 123, 10, 0, 0, 3, 32, 16, 124, 0, 3, 34, 17, 125, 0, 1, 133, 0, 0, 0, 3, 34, 17, 127, 0, 3, 18, 9, 128, 0, 3, 34, 17, 130, 0, 5, 131, 10, 0, 0, 1, 129, 0, 0, 0, 1, 131, 0, 0, 0, 1, 133, 0, 0, 0, 1, 119, 0, 0, 0, 1, 126, 0, 0, 0, 1, 33, 0, 0, 0, 5, 136, 3, 0, 0, 1, 134, 0, 0, 0, 1, 136, 0, 0, 0, 1, 137, 0, 0, 0, 5, 139, 2, 0, 0, 1, 135, 0, 0, 0, 1, 142, 0, 0, 0, 1, 138, 0, 0, 0, 1, 141, 0, 0, 0, 1, 35, 0, 0, 0, 1, 140, 0, 0, 0, 3, 38, 19, 146, 0, 3, 46, 23, 146, 0, 1, 143, 0, 0, 0, 1, 144, 0, 0, 0, 1, 37, 0, 0, 0, 5, 148, 4, 0, 0, 3, 8, 4, 149, 0, 5, 150, 6, 0, 0, 1, 39, 0, 0, 0, 5, 152, 15, 0, 0, 3, 34, 17, 153, 0, 3, 42, 21, 154, 0, 3, 34, 17, 155, 0, 5, 156, 31, 0, 0, 1, 41, 0, 0, 0, 3, 44, 22, 159, 0, 1, 157, 0, 0, 0, 1, 159, 0, 0, 0, 1, 43, 0, 0, 0, 3, 8, 4, 161, 0, 5, 162, 8, 0, 0, 3, 18, 9, 163, 0, 3, 34, 17, 169, 0, 5, 165, 10, 0, 0, 3, 34, 17, 167, 0, 3, 44, 22, 168, 0, 1, 166, 0, 0, 0, 1, 168, 0, 0, 0, 1, 170, 0, 0, 0, 1, 164, 0, 0, 0, 1, 170, 0, 0, 0, 1, 45, 0, 0, 0, 5, 172, 5, 0, 0, 3, 8, 4, 173, 0, 5, 174, 7, 0, 0, 1, 47, 0, 0, 0, 0, 1, 1, 0, 2, 1, 2, 1, 2, 2, 3, 1, 1, 4, 2, 4, 1, 1, 6, 2, 5, 1, 1, 8, 2, 11, 12, 11, 12, 17, 18, 22, 25, 19, 21, 26, 29, 6144, 0, 0, 0, 399360, 0, 0, 0, 62914560, 0, 0, 0, 3670016, 0, 0, 0, 1006632960, 0, 0, 0, 53, 65, 68, 76, 80, 91, 100, 114, 130, 132, 135, 140, 145, 158, 167, 169, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47];
static ATN_CELL: OnceLock<ParserAtn> = OnceLock::new();

/// Validates and caches the packed grammar ATN for all parser instances.
fn atn() -> &'static ParserAtn {
    ATN_CELL.get_or_init(|| {
        ParserAtn::from_static(PARSER_ATN_DATA)
            .unwrap_or_else(|error| panic!("generated parser ATN is incompatible with this runtime: {error}"))
    })
}

/// Borrows the validated packed parser ATN embedded in this module.
pub fn parser_atn() -> &'static ParserAtn {
    atn()
}

/// Result from [`parse_with_parser`] or [`parse_stream_with_parser`].
///
/// Keeps the generated parser available after the entry rule runs so callers
/// can inspect diagnostics or recover the parser-owned token stream.
#[derive(Debug)]
pub struct TomlParserParseOutput<R, L>
where
    L: TokenSource,
{
    pub result: R,
    pub parser: TomlParser<L>,
}

impl<L: TokenSource> TomlParserParseOutput<antlr4_runtime::NodeId, L> {
    /// Validates a completed parse and changes its generated context surface.
    ///
    /// Validation rejects lexer diagnostics, parser recovery, recovered error
    /// nodes, and missing generated required children before constructing the
    /// validated-tree type boundary.
    pub fn validate(self) -> Result<TomlValidatedTree, TomlValidationError> {
        let lexer = self.parser.token_stream().number_of_source_errors();
        let parser = self.parser.number_of_syntax_errors();
        if lexer != 0 || parser != 0 {
            return Err(TomlValidationError::SyntaxErrors { lexer, parser });
        }
        let parsed = self.parser.into_parsed_file(self.result);
        validate_tree_structure(&parsed)?;
        Ok(TomlValidatedTree::__new(parsed))
    }
}

/// Parses UTF-8 text by constructing the lexer, token stream, parser, and
/// caller-selected entry rule in one call.
///
/// Pass the generated lexer constructor and a parser entry rule, for example
/// `parse(src, MyGrammarLexer::new, TomlParser::file)`.
///
/// The returned [`antlr4_runtime::ParsedFile`] owns the canonical token store,
/// flat CST storage, and entry-rule root.
/// Use [`parse_with_parser`] instead when the caller also needs parser
/// diagnostics after the entry rule runs.
pub fn parse<L: TokenSource>(
    input: impl AsRef<str>,
    lexer: impl FnOnce(antlr4_runtime::InputStream) -> L,
    entry: impl FnOnce(&mut TomlParser<L>) -> Result<antlr4_runtime::NodeId, antlr4_runtime::AntlrError>,
) -> Result<antlr4_runtime::ParsedFile, antlr4_runtime::AntlrError>
{
    parse_stream(antlr4_runtime::InputStream::new(input.as_ref()), lexer, entry)
}

/// Parses UTF-8 text and returns a typed tree whose required generated child
/// accessors are infallible.
pub fn parse_validated<L: TokenSource>(
    input: impl AsRef<str>,
    lexer: impl FnOnce(antlr4_runtime::InputStream) -> L,
    entry: impl FnOnce(&mut TomlParser<L>) -> Result<antlr4_runtime::NodeId, antlr4_runtime::AntlrError>,
) -> Result<TomlValidatedTree, TomlValidationError>
{
    parse_stream_validated(
        antlr4_runtime::InputStream::new(input.as_ref()),
        lexer,
        entry,
    )
}

/// Parses UTF-8 text like [`parse`] while returning the parser after the entry
/// rule has run.
///
/// This keeps the compact generated setup path available for callers that also
/// need `Parser::number_of_syntax_errors()` or `TomlParser::into_token_stream()`.
pub fn parse_with_parser<L: TokenSource, R>(
    input: impl AsRef<str>,
    lexer: impl FnOnce(antlr4_runtime::InputStream) -> L,
    entry: impl FnOnce(&mut TomlParser<L>) -> Result<R, antlr4_runtime::AntlrError>,
) -> Result<TomlParserParseOutput<R, L>, antlr4_runtime::AntlrError>
{
    parse_stream_with_parser(
        antlr4_runtime::InputStream::new(input.as_ref()),
        lexer,
        entry,
    )
}

/// Parses a caller-provided character stream by constructing the lexer, token
/// stream, parser, and caller-selected entry rule in one call.
///
/// Unlike [`parse`], this accepts any [`antlr4_runtime::CharStream`], including
/// a named [`antlr4_runtime::InputStream`] or a byte-oriented
/// [`antlr4_runtime::ByteStream`].
pub fn parse_stream<I: antlr4_runtime::CharStream, L: TokenSource>(
    input: I,
    lexer: impl FnOnce(I) -> L,
    entry: impl FnOnce(&mut TomlParser<L>) -> Result<antlr4_runtime::NodeId, antlr4_runtime::AntlrError>,
) -> Result<antlr4_runtime::ParsedFile, antlr4_runtime::AntlrError>
{
    let TomlParserParseOutput { result, parser } =
        parse_stream_with_parser(input, lexer, entry)?;
    Ok(parser.into_parsed_file(result))
}

/// Parses a caller-provided character stream and validates the completed tree.
pub fn parse_stream_validated<I: antlr4_runtime::CharStream, L: TokenSource>(
    input: I,
    lexer: impl FnOnce(I) -> L,
    entry: impl FnOnce(&mut TomlParser<L>) -> Result<antlr4_runtime::NodeId, antlr4_runtime::AntlrError>,
) -> Result<TomlValidatedTree, TomlValidationError>
{
    let output = parse_stream_with_parser(input, lexer, entry)
        .map_err(TomlValidationError::Recognition)?;
    output.validate()
}

/// Parses a caller-provided character stream like [`parse_stream`] while
/// returning the parser after the entry rule has run.
pub fn parse_stream_with_parser<I: antlr4_runtime::CharStream, L: TokenSource, R>(
    input: I,
    lexer: impl FnOnce(I) -> L,
    entry: impl FnOnce(&mut TomlParser<L>) -> Result<R, antlr4_runtime::AntlrError>,
) -> Result<TomlParserParseOutput<R, L>, antlr4_runtime::AntlrError>
{
    let lexer = lexer(input);
    let tokens = CommonTokenStream::new(lexer);
    let mut parser = TomlParser::new(tokens);
    let result = entry(&mut parser)?;
    Ok(TomlParserParseOutput { result, parser })
}

/// Generated parser. Each grammar rule is exposed as a public method.
///
/// Pick an entry-rule method that matches the grammar's intended
/// top-level construct for the input being parsed. The generator can
/// infer entry candidates from call paths that reach explicit `EOF`
/// matches, from parser rules that no other rule calls, and from
/// configured entry rules. It cannot infer the semantic choice
/// between multiple candidates.
///
/// Likely parser entry-rule methods:
/// - `document()`
///
/// All parser rule methods:
/// - `document()`
/// - `expression()`
/// - `comment()`
/// - `key_value()`
/// - `key()`
/// - `simple_key()`
/// - `unquoted_key()`
/// - `quoted_key()`
/// - `dotted_key()`
/// - `value()`
/// - `string()`
/// - `integer()`
/// - `floating_point()`
/// - `bool()`
/// - `date_time()`
/// - `array()`
/// - `array_values()`
/// - `comment_or_nl()`
/// - `table()`
/// - `standard_table()`
/// - `inline_table()`
/// - `inline_table_keyvals()`
/// - `inline_table_keyvals_non_empty()`
/// - `array_table()`
#[derive(Debug)]
pub struct TomlParser<L, H = antlr4_runtime::NoSemanticHooks>
where
    L: TokenSource,
    H: antlr4_runtime::SemanticHooks,
{
    base: BaseParser<L, H>,
    simulator: Option<antlr4_runtime::ParserAtnSimulator<'static>>,
    generated_only: bool,
}

#[allow(dead_code)]
#[derive(Debug)]
enum GeneratedRuleError {
    Fatal(antlr4_runtime::AntlrError),
    Interpreted(antlr4_runtime::AntlrError),
}

impl GeneratedRuleError {
    fn into_error(self) -> antlr4_runtime::AntlrError {
        match self {
            Self::Fatal(error) | Self::Interpreted(error) => error,
        }
    }
}
impl<L> TomlParser<L, antlr4_runtime::NoSemanticHooks>
where
    L: TokenSource,
{
    pub fn new(input: CommonTokenStream<L>) -> Self {
        Self::with_hooks(input, antlr4_runtime::NoSemanticHooks)
    }
}

impl<L, H> TomlParser<L, H>
where
    L: TokenSource,
    H: antlr4_runtime::SemanticHooks,
{
    pub fn with_hooks(input: CommonTokenStream<L>, hooks: H) -> Self {
        let grammar_metadata = metadata();
        let data = grammar_metadata.recognizer_data();
        let mut base = BaseParser::with_semantic_hooks(input, data, hooks);
        base.set_unknown_predicate_policy(antlr4_runtime::UnknownSemanticPolicy::Error);
        Self {
            base,
            simulator: None,
            generated_only: std::env::var_os("ANTLR4_RUST_GENERATED_ONLY").is_some(),
        }
    }

    #[allow(dead_code)]
    fn parse_rule(&mut self, rule_index: usize) -> Result<antlr4_runtime::ParseTree, antlr4_runtime::AntlrError> {
        self.parse_rule_precedence(rule_index, 0)
    }

    #[allow(dead_code)]
    fn parse_rule_precedence(&mut self, rule_index: usize, precedence: i32) -> Result<antlr4_runtime::ParseTree, antlr4_runtime::AntlrError> {
        self.parse_rule_precedence_inner(rule_index, precedence, true)
    }

    #[allow(dead_code)]
    fn parse_rule_precedence_from_generated(&mut self, rule_index: usize, precedence: i32) -> Result<antlr4_runtime::ParseTree, antlr4_runtime::AntlrError> {
        self.parse_rule_precedence_inner(rule_index, precedence, false)
    }

    #[allow(dead_code)]
    fn parse_rule_precedence_inner(&mut self, rule_index: usize, precedence: i32, allow_generated_fallback: bool) -> Result<antlr4_runtime::ParseTree, antlr4_runtime::AntlrError> {
        if allow_generated_fallback {
            // True top-level entry: drop any fail-loud coordinates left by a
            // previous parse so a reused parser starts clean. Mid-parse the hits
            // are preserved so a generated parent can surface a recovered child's
            // fail-loud coordinate at this boundary.
            self.base.reset_unknown_semantic_hits();
            // Likewise drop stale sticky aborts (depth-cap violation,
            // parse-listener abort): entry rules share one parser instance,
            // and the flags must not poison the next parse when the previous
            // one exited through an error path.
            let _ = self.base.take_parse_abort();
        }
        let __rule_start = antlr4_runtime::IntStream::index(self.base.input());
        let __generated_only = self.generated_only();
        let __tree = if let Some(result) = self.parse_generated_rule(rule_index, precedence, allow_generated_fallback) {
            match result {
                Ok(tree) => tree,
                Err(error) => {
                    antlr4_runtime::IntStream::seek(self.base.input(), __rule_start);
                    let __report_error =
                        matches!(&error, GeneratedRuleError::Fatal(_));
                    // A fatal unwind retains recovery diagnostics committed
                    // earlier in this entry. Dispatch them before a semantic
                    // or parser-abort override can return, or they would leak
                    // into the next entry on a reused parser.
                    if allow_generated_fallback && __report_error {
                        self.base.report_generated_parser_diagnostics();
                    }
                    if allow_generated_fallback {
                        // A sticky abort (depth cap, listener) wins over an
                        // error or semantic miss derived after recovery absorbed
                        // the aborted rule. Drain any masked semantic miss too,
                        // so neither condition poisons the next entry.
                        if let Some(abort) = self.base.take_parse_abort() {
                            let _ = self.base.take_unknown_semantic_error();
                            return Err(abort);
                        }
                        // A generated predicate that consulted an unimplemented
                        // hook fails the alternative and surfaces here as a generic
                        // failed-predicate/rule error. Prefer the recorded fail-loud
                        // semantic error when no parser abort occurred.
                        if let Some(semantic_error) = self.base.take_unknown_semantic_error() {
                            return Err(semantic_error);
                        }
                    }
                    let error = error.into_error();
                    if allow_generated_fallback && __report_error {
                        self.base.report_unrecovered_parser_error(&error);
                    }
                    return Err(error);
                }
            }
        } else if __generated_only {
            return Err(antlr4_runtime::AntlrError::Unsupported(format!("generated parser did not emit rule {}", rule_index)));
        } else {
            self.parse_interpreted_rule_precedence(rule_index, precedence)?
        };
        if allow_generated_fallback {
            self.base.report_generated_parser_diagnostics();
            // A sticky abort (depth-cap violation, listener abort) is not a
            // syntax error: rule-level recovery may have produced a tree
            // and semantic miss anyway, but the abort is the root cause. Drain
            // both sticky conditions before returning so parser reuse is clean.
            if let Some(error) = self.base.take_parse_abort() {
                let _ = self.base.take_unknown_semantic_error();
                return Err(error);
            }
            // Surface unknown predicate/action coordinates recorded under the
            // Error policy only after parser aborts have been ruled out.
            if let Some(error) = self.base.take_unknown_semantic_error() {
                return Err(error);
            }
        }
        Ok(__tree)
    }

    #[allow(dead_code)]
    fn parse_interpreted_rule(&mut self, rule_index: usize) -> Result<antlr4_runtime::ParseTree, antlr4_runtime::AntlrError> {
        self.parse_interpreted_rule_precedence(rule_index, 0)
    }

    #[allow(dead_code)]
    fn parse_interpreted_rule_precedence(&mut self, rule_index: usize, precedence: i32) -> Result<antlr4_runtime::ParseTree, antlr4_runtime::AntlrError> {
        if precedence == 0 && false && std::env::var_os("ANTLR4_RUST_ADAPTIVE_DIRECT").is_some() {
            let simulator = self
                .simulator
                .get_or_insert_with(|| antlr4_runtime::ParserAtnSimulator::new_shared(atn()));
            self.base
                .parse_atn_rule_adaptive_or_fallback(atn(), simulator, rule_index)
        } else {
        let (tree, actions) = self.base.parse_atn_rule_with_runtime_options_and_precedence(atn(), rule_index, precedence, antlr4_runtime::ParserRuntimeOptions { action_indices: &[], track_alt_numbers: false, track_context_alt_numbers: false, predicates: &[], semantics: Some(parser_semantics()), rule_args: &[], member_actions: &[], return_actions: &[], unknown_predicate_policy: antlr4_runtime::UnknownSemanticPolicy::Error , ..antlr4_runtime::ParserRuntimeOptions::default() })?;
        let _ = actions;
        Ok(tree)
        }
    }

    #[allow(dead_code)]
    fn parse_generated_rule(&mut self, rule_index: usize, precedence: i32, allow_fallback: bool) -> Option<Result<antlr4_runtime::ParseTree, GeneratedRuleError>> {
        let _ = precedence;
        let _ = allow_fallback;
        match rule_index {
            0 => Some(self.parse_generated_rule_0_dispatch(precedence, allow_fallback)),
            1 => Some(self.parse_generated_rule_1_dispatch(precedence, allow_fallback)),
            2 => Some(self.parse_generated_rule_2_dispatch(precedence, allow_fallback)),
            3 => Some(self.parse_generated_rule_3_dispatch(precedence, allow_fallback)),
            4 => Some(self.parse_generated_rule_4_dispatch(precedence, allow_fallback)),
            5 => Some(self.parse_generated_rule_5_dispatch(precedence, allow_fallback)),
            6 => Some(self.parse_generated_rule_6_dispatch(precedence, allow_fallback)),
            7 => Some(self.parse_generated_rule_7_dispatch(precedence, allow_fallback)),
            8 => Some(self.parse_generated_rule_8_dispatch(precedence, allow_fallback)),
            9 => Some(self.parse_generated_rule_9_dispatch(precedence, allow_fallback)),
            10 => Some(self.parse_generated_rule_10_dispatch(precedence, allow_fallback)),
            11 => Some(self.parse_generated_rule_11_dispatch(precedence, allow_fallback)),
            12 => Some(self.parse_generated_rule_12_dispatch(precedence, allow_fallback)),
            13 => Some(self.parse_generated_rule_13_dispatch(precedence, allow_fallback)),
            14 => Some(self.parse_generated_rule_14_dispatch(precedence, allow_fallback)),
            15 => Some(self.parse_generated_rule_15_dispatch(precedence, allow_fallback)),
            16 => Some(self.parse_generated_rule_16_dispatch(precedence, allow_fallback)),
            17 => Some(self.parse_generated_rule_17_dispatch(precedence, allow_fallback)),
            18 => Some(self.parse_generated_rule_18_dispatch(precedence, allow_fallback)),
            19 => Some(self.parse_generated_rule_19_dispatch(precedence, allow_fallback)),
            20 => Some(self.parse_generated_rule_20_dispatch(precedence, allow_fallback)),
            21 => Some(self.parse_generated_rule_21_dispatch(precedence, allow_fallback)),
            22 => Some(self.parse_generated_rule_22_dispatch(precedence, allow_fallback)),
            23 => Some(self.parse_generated_rule_23_dispatch(precedence, allow_fallback)),
            _ => None,
        }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_0_dispatch(&mut self, precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! { dispatch self, 0, GeneratedRuleError::Fatal; self.parse_generated_rule_0(precedence, allow_fallback) }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_0(&mut self, __precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = __precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! {
            ordinary self, 0isize, 0, allow_fallback, atn(), GeneratedRuleError::Fatal;
            retry [none];
            bind (__ctx, __rule_start, __consumed_eof, __sync_error);
            setup {}
            body {
                antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 48isize, self.parse_generated_rule_1_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                let mut __loop_iter_53 = false;
                loop {
                    self.base.sync_into(atn(), 53, &mut __ctx, __loop_iter_53, &mut __sync_error)?;
                    let __decision_start = antlr4_runtime::IntStream::index(self.base.input());
                    let __prediction = match self.base.la(1) {
                        2 => antlr4_runtime::ParserAtnPrediction { alt: 1, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                        -1 => antlr4_runtime::ParserAtnPrediction { alt: 2, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                        _ => return Err(self.base.no_viable_alternative_error(__decision_start)),
                    };
                    self.base.record_generated_prediction_diagnostic(atn(), 53, &__prediction);
                    match __prediction.alt {
                        1 => {
                            __loop_iter_53 = true;
                            self.base.match_token_into(2, 50, atn(), &mut __ctx, &mut __consumed_eof)?;
                            antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 50isize, self.parse_generated_rule_1_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                        }
                        2 => {
                            break;
                        }
                        _ => return Err(self.base.no_viable_alternative_error(__decision_start)),
                    }
                }
                self.base.match_token_into(-1, 57, atn(), &mut __ctx, &mut __consumed_eof)?;
            }
            success {}
            recovery {}
        }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_1_dispatch(&mut self, precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! { dispatch self, 1, GeneratedRuleError::Fatal; self.parse_generated_rule_1(precedence, allow_fallback) }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_1(&mut self, __precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = __precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! {
            ordinary self, 2isize, 1, allow_fallback, atn(), GeneratedRuleError::Fatal;
            retry [none];
            bind (__ctx, __rule_start, __consumed_eof, __sync_error);
            setup {}
            body {
                self.base.sync_into(atn(), 65, &mut __ctx, false, &mut __sync_error)?;
                let __decision_start = antlr4_runtime::IntStream::index(self.base.input());
                let __prediction = match self.base.la(1) {
                    11..=13 => antlr4_runtime::ParserAtnPrediction { alt: 1, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                    4..=5 => antlr4_runtime::ParserAtnPrediction { alt: 2, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                    -1 | 2..=3 => antlr4_runtime::ParserAtnPrediction { alt: 3, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                    _ => antlr4_runtime::ParserAtnPrediction { alt: 3, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                };
                self.base.record_generated_prediction_diagnostic(atn(), 65, &__prediction);
                match __prediction.alt {
                    1 => {
                        antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 58isize, self.parse_generated_rule_3_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                        antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 59isize, self.parse_generated_rule_2_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                    }
                    2 => {
                        antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 61isize, self.parse_generated_rule_18_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                        antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 62isize, self.parse_generated_rule_2_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                    }
                    3 => {
                        antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 64isize, self.parse_generated_rule_2_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                    }
                    _ => return Err(self.base.no_viable_alternative_error(__decision_start)),
                }
            }
            success {}
            recovery {}
        }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_2_dispatch(&mut self, precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! { dispatch self, 2, GeneratedRuleError::Fatal; self.parse_generated_rule_2(precedence, allow_fallback) }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_2(&mut self, __precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = __precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! {
            ordinary self, 4isize, 2, allow_fallback, atn(), GeneratedRuleError::Fatal;
            retry [none];
            bind (__ctx, __rule_start, __consumed_eof, __sync_error);
            setup {}
            body {
                self.base.sync_into(atn(), 68, &mut __ctx, false, &mut __sync_error)?;
                let __decision_start = antlr4_runtime::IntStream::index(self.base.input());
                let __prediction = match self.base.la(1) {
                    3 => antlr4_runtime::ParserAtnPrediction { alt: 1, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                    -1 | 2 => antlr4_runtime::ParserAtnPrediction { alt: 2, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                    _ => antlr4_runtime::ParserAtnPrediction { alt: 2, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                };
                self.base.record_generated_prediction_diagnostic(atn(), 68, &__prediction);
                match __prediction.alt {
                    1 => {
                        self.base.match_token_into(3, 69, atn(), &mut __ctx, &mut __consumed_eof)?;
                    }
                    2 => {
                    }
                    _ => return Err(self.base.no_viable_alternative_error(__decision_start)),
                }
            }
            success {}
            recovery {}
        }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_3_dispatch(&mut self, precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! { dispatch self, 3, GeneratedRuleError::Fatal; self.parse_generated_rule_3(precedence, allow_fallback) }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_3(&mut self, __precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = __precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! {
            ordinary self, 6isize, 3, allow_fallback, atn(), GeneratedRuleError::Fatal;
            retry [none];
            bind (__ctx, __rule_start, __consumed_eof, __sync_error);
            setup {}
            body {
                antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 70isize, self.parse_generated_rule_4_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                self.base.match_token_into(8, 72, atn(), &mut __ctx, &mut __consumed_eof)?;
                antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 72isize, self.parse_generated_rule_9_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
            }
            success {}
            recovery {}
        }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_4_dispatch(&mut self, precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! { dispatch self, 4, GeneratedRuleError::Fatal; self.parse_generated_rule_4(precedence, allow_fallback) }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_4(&mut self, __precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = __precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! {
            ordinary self, 8isize, 4, allow_fallback, atn(), GeneratedRuleError::Fatal;
            retry [none];
            bind (__ctx, __rule_start, __consumed_eof, __sync_error);
            setup {}
            body {
                self.base.sync_into(atn(), 76, &mut __ctx, false, &mut __sync_error)?;
                let __decision_start = antlr4_runtime::IntStream::index(self.base.input());
                let __prediction = if let Some(__prediction) = self.base.ll1_decision_prediction(atn(), 76) {
                    __prediction
                } else {
                    let __prediction = {
                        let __simulator = self.simulator.get_or_insert_with(|| antlr4_runtime::ParserAtnSimulator::new_shared(atn()));
                        __simulator.adaptive_predict_stream_info_sll_probe(3, 0, self.base.input())
                            .map_err(|__error| match __error {
                                antlr4_runtime::ParserAtnSimulatorError::NoViableAlt { index, .. } => self.base.no_viable_alternative_error_at(__decision_start, index),
                                _ => self.base.no_viable_alternative_error(__decision_start),
                            })?
                    };
                    if __prediction.requires_full_context && self.base.prediction_mode() != antlr4_runtime::PredictionMode::Sll {
                        let __simulator = self.simulator.get_or_insert_with(|| antlr4_runtime::ParserAtnSimulator::new_shared(atn()));
                        let __prediction_context = __simulator.intern_prediction_context(self.base.rule_context_version(), self.base.prediction_context_return_states(atn()));
                        __simulator.set_exact_ambig_detection(self.base.prediction_mode() == antlr4_runtime::PredictionMode::LlExactAmbigDetection);
                        __simulator.adaptive_predict_stream_info_with_context(3, 0, self.base.input(), __prediction_context)
                            .map_err(|__error| match __error {
                                antlr4_runtime::ParserAtnSimulatorError::NoViableAlt { index, .. } => self.base.no_viable_alternative_error_at(__decision_start, index),
                                _ => self.base.no_viable_alternative_error(__decision_start),
                            })?
                    } else {
                        __prediction
                    }
                };
                self.base.record_generated_prediction_diagnostic(atn(), 76, &__prediction);
                match __prediction.alt {
                    1 => {
                        antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 74isize, self.parse_generated_rule_5_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                    }
                    2 => {
                        antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 75isize, self.parse_generated_rule_8_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                    }
                    _ => return Err(self.base.no_viable_alternative_error(__decision_start)),
                }
            }
            success {}
            recovery {}
        }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_5_dispatch(&mut self, precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! { dispatch self, 5, GeneratedRuleError::Fatal; self.parse_generated_rule_5(precedence, allow_fallback) }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_5(&mut self, __precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = __precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! {
            ordinary self, 10isize, 5, allow_fallback, atn(), GeneratedRuleError::Fatal;
            retry [none];
            bind (__ctx, __rule_start, __consumed_eof, __sync_error);
            setup {}
            body {
                let mut __decision_start = antlr4_runtime::IntStream::index(self.base.input());
                let __prediction = match self.base.la(1) {
                    11..=12 => antlr4_runtime::ParserAtnPrediction { alt: 1, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                    13 => antlr4_runtime::ParserAtnPrediction { alt: 2, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                    _ => {
                        self.base.sync_into(atn(), 80, &mut __ctx, false, &mut __sync_error)?;
                        __decision_start = antlr4_runtime::IntStream::index(self.base.input());
                        match self.base.la(1) {
                            11..=12 => antlr4_runtime::ParserAtnPrediction { alt: 1, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                            13 => antlr4_runtime::ParserAtnPrediction { alt: 2, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                            _ => return Err(self.base.no_viable_alternative_error(__decision_start)),
                        }
                    }
                };
                self.base.record_generated_prediction_diagnostic(atn(), 80, &__prediction);
                match __prediction.alt {
                    1 => {
                        antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 78isize, self.parse_generated_rule_7_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                    }
                    2 => {
                        antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 79isize, self.parse_generated_rule_6_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                    }
                    _ => return Err(self.base.no_viable_alternative_error(__decision_start)),
                }
            }
            success {}
            recovery {}
        }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_6_dispatch(&mut self, precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! { dispatch self, 6, GeneratedRuleError::Fatal; self.parse_generated_rule_6(precedence, allow_fallback) }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_6(&mut self, __precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = __precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! {
            ordinary self, 12isize, 6, allow_fallback, atn(), GeneratedRuleError::Fatal;
            retry [none];
            bind (__ctx, __rule_start, __consumed_eof, __sync_error);
            setup {}
            body {
                self.base.match_token_into(13, 83, atn(), &mut __ctx, &mut __consumed_eof)?;
            }
            success {}
            recovery {}
        }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_7_dispatch(&mut self, precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! { dispatch self, 7, GeneratedRuleError::Fatal; self.parse_generated_rule_7(precedence, allow_fallback) }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_7(&mut self, __precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = __precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! {
            ordinary self, 14isize, 7, allow_fallback, atn(), GeneratedRuleError::Fatal;
            retry [none];
            bind (__ctx, __rule_start, __consumed_eof, __sync_error);
            setup {}
            body {
                self.base.match_set_into(&[(11, 12)], 85, atn(), &mut __ctx, &mut __consumed_eof)?;
            }
            success {}
            recovery {}
        }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_8_dispatch(&mut self, precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! { dispatch self, 8, GeneratedRuleError::Fatal; self.parse_generated_rule_8(precedence, allow_fallback) }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_8(&mut self, __precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = __precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! {
            ordinary self, 16isize, 8, allow_fallback, atn(), GeneratedRuleError::Fatal;
            retry [none];
            bind (__ctx, __rule_start, __consumed_eof, __sync_error);
            setup {}
            body {
                antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 86isize, self.parse_generated_rule_5_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                self.base.match_token_into(9, 88, atn(), &mut __ctx, &mut __consumed_eof)?;
                antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 88isize, self.parse_generated_rule_5_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                let mut __loop_iter_91 = true;
                loop {
                    self.base.sync_into(atn(), 91, &mut __ctx, __loop_iter_91, &mut __sync_error)?;
                    let __decision_start = antlr4_runtime::IntStream::index(self.base.input());
                    let __prediction = match self.base.la(1) {
                        9 => antlr4_runtime::ParserAtnPrediction { alt: 1, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                        6..=8 => antlr4_runtime::ParserAtnPrediction { alt: 2, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                        _ => antlr4_runtime::ParserAtnPrediction { alt: 2, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                    };
                    self.base.record_generated_prediction_diagnostic(atn(), 91, &__prediction);
                    match __prediction.alt {
                        1 => {
                            __loop_iter_91 = true;
                            self.base.match_token_into(9, 88, atn(), &mut __ctx, &mut __consumed_eof)?;
                            antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 88isize, self.parse_generated_rule_5_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                        }
                        2 => {
                            break;
                        }
                        _ => return Err(self.base.no_viable_alternative_error(__decision_start)),
                    }
                }
            }
            success {}
            recovery {}
        }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_9_dispatch(&mut self, precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! { dispatch self, 9, GeneratedRuleError::Fatal; self.parse_generated_rule_9(precedence, allow_fallback) }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_9(&mut self, __precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = __precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! {
            ordinary self, 18isize, 9, allow_fallback, atn(), GeneratedRuleError::Fatal;
            retry [none];
            bind (__ctx, __rule_start, __consumed_eof, __sync_error);
            setup {}
            body {
                let mut __decision_start = antlr4_runtime::IntStream::index(self.base.input());
                let __prediction = match self.base.la(1) {
                    11..=12 | 17..=18 => antlr4_runtime::ParserAtnPrediction { alt: 1, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                    22..=25 => antlr4_runtime::ParserAtnPrediction { alt: 2, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                    19..=21 => antlr4_runtime::ParserAtnPrediction { alt: 3, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                    16 => antlr4_runtime::ParserAtnPrediction { alt: 4, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                    26..=29 => antlr4_runtime::ParserAtnPrediction { alt: 5, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                    4 => antlr4_runtime::ParserAtnPrediction { alt: 6, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                    15 => antlr4_runtime::ParserAtnPrediction { alt: 7, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                    _ => {
                        self.base.sync_into(atn(), 100, &mut __ctx, false, &mut __sync_error)?;
                        __decision_start = antlr4_runtime::IntStream::index(self.base.input());
                        match self.base.la(1) {
                            11..=12 | 17..=18 => antlr4_runtime::ParserAtnPrediction { alt: 1, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                            22..=25 => antlr4_runtime::ParserAtnPrediction { alt: 2, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                            19..=21 => antlr4_runtime::ParserAtnPrediction { alt: 3, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                            16 => antlr4_runtime::ParserAtnPrediction { alt: 4, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                            26..=29 => antlr4_runtime::ParserAtnPrediction { alt: 5, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                            4 => antlr4_runtime::ParserAtnPrediction { alt: 6, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                            15 => antlr4_runtime::ParserAtnPrediction { alt: 7, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                            _ => return Err(self.base.no_viable_alternative_error(__decision_start)),
                        }
                    }
                };
                self.base.record_generated_prediction_diagnostic(atn(), 100, &__prediction);
                match __prediction.alt {
                    1 => {
                        antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 93isize, self.parse_generated_rule_10_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                    }
                    2 => {
                        antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 94isize, self.parse_generated_rule_11_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                    }
                    3 => {
                        antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 95isize, self.parse_generated_rule_12_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                    }
                    4 => {
                        antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 96isize, self.parse_generated_rule_13_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                    }
                    5 => {
                        antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 97isize, self.parse_generated_rule_14_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                    }
                    6 => {
                        antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 98isize, self.parse_generated_rule_15_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                    }
                    7 => {
                        antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 99isize, self.parse_generated_rule_20_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                    }
                    _ => return Err(self.base.no_viable_alternative_error(__decision_start)),
                }
            }
            success {}
            recovery {}
        }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_10_dispatch(&mut self, precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! { dispatch self, 10, GeneratedRuleError::Fatal; self.parse_generated_rule_10(precedence, allow_fallback) }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_10(&mut self, __precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = __precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! {
            ordinary self, 20isize, 10, allow_fallback, atn(), GeneratedRuleError::Fatal;
            retry [none];
            bind (__ctx, __rule_start, __consumed_eof, __sync_error);
            setup {}
            body {
                self.base.match_set_into(&[(11, 12), (17, 18)], 103, atn(), &mut __ctx, &mut __consumed_eof)?;
            }
            success {}
            recovery {}
        }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_11_dispatch(&mut self, precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! { dispatch self, 11, GeneratedRuleError::Fatal; self.parse_generated_rule_11(precedence, allow_fallback) }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_11(&mut self, __precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = __precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! {
            ordinary self, 22isize, 11, allow_fallback, atn(), GeneratedRuleError::Fatal;
            retry [none];
            bind (__ctx, __rule_start, __consumed_eof, __sync_error);
            setup {}
            body {
                self.base.match_set_into(&[(22, 25)], 105, atn(), &mut __ctx, &mut __consumed_eof)?;
            }
            success {}
            recovery {}
        }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_12_dispatch(&mut self, precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! { dispatch self, 12, GeneratedRuleError::Fatal; self.parse_generated_rule_12(precedence, allow_fallback) }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_12(&mut self, __precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = __precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! {
            ordinary self, 24isize, 12, allow_fallback, atn(), GeneratedRuleError::Fatal;
            retry [none];
            bind (__ctx, __rule_start, __consumed_eof, __sync_error);
            setup {}
            body {
                self.base.match_set_into(&[(19, 21)], 107, atn(), &mut __ctx, &mut __consumed_eof)?;
            }
            success {}
            recovery {}
        }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_13_dispatch(&mut self, precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! { dispatch self, 13, GeneratedRuleError::Fatal; self.parse_generated_rule_13(precedence, allow_fallback) }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_13(&mut self, __precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = __precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! {
            ordinary self, 26isize, 13, allow_fallback, atn(), GeneratedRuleError::Fatal;
            retry [none];
            bind (__ctx, __rule_start, __consumed_eof, __sync_error);
            setup {}
            body {
                self.base.match_token_into(16, 109, atn(), &mut __ctx, &mut __consumed_eof)?;
            }
            success {}
            recovery {}
        }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_14_dispatch(&mut self, precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! { dispatch self, 14, GeneratedRuleError::Fatal; self.parse_generated_rule_14(precedence, allow_fallback) }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_14(&mut self, __precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = __precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! {
            ordinary self, 28isize, 14, allow_fallback, atn(), GeneratedRuleError::Fatal;
            retry [none];
            bind (__ctx, __rule_start, __consumed_eof, __sync_error);
            setup {}
            body {
                self.base.match_set_into(&[(26, 29)], 111, atn(), &mut __ctx, &mut __consumed_eof)?;
            }
            success {}
            recovery {}
        }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_15_dispatch(&mut self, precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! { dispatch self, 15, GeneratedRuleError::Fatal; self.parse_generated_rule_15(precedence, allow_fallback) }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_15(&mut self, __precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = __precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! {
            ordinary self, 30isize, 15, allow_fallback, atn(), GeneratedRuleError::Fatal;
            retry [none];
            bind (__ctx, __rule_start, __consumed_eof, __sync_error);
            setup {}
            body {
                self.base.match_token_into(4, 114, atn(), &mut __ctx, &mut __consumed_eof)?;
                self.base.sync_into(atn(), 114, &mut __ctx, false, &mut __sync_error)?;
                let __decision_start = antlr4_runtime::IntStream::index(self.base.input());
                let __prediction = if let Some(__prediction) = self.base.ll1_decision_prediction(atn(), 114) {
                    __prediction
                } else {
                    let __prediction = {
                        let __simulator = self.simulator.get_or_insert_with(|| antlr4_runtime::ParserAtnSimulator::new_shared(atn()));
                        __simulator.adaptive_predict_stream_info_sll_probe(7, 0, self.base.input())
                            .map_err(|__error| match __error {
                                antlr4_runtime::ParserAtnSimulatorError::NoViableAlt { index, .. } => self.base.no_viable_alternative_error_at(__decision_start, index),
                                _ => self.base.no_viable_alternative_error(__decision_start),
                            })?
                    };
                    if __prediction.requires_full_context && self.base.prediction_mode() != antlr4_runtime::PredictionMode::Sll {
                        let __simulator = self.simulator.get_or_insert_with(|| antlr4_runtime::ParserAtnSimulator::new_shared(atn()));
                        let __prediction_context = __simulator.intern_prediction_context(self.base.rule_context_version(), self.base.prediction_context_return_states(atn()));
                        __simulator.set_exact_ambig_detection(self.base.prediction_mode() == antlr4_runtime::PredictionMode::LlExactAmbigDetection);
                        __simulator.adaptive_predict_stream_info_with_context(7, 0, self.base.input(), __prediction_context)
                            .map_err(|__error| match __error {
                                antlr4_runtime::ParserAtnSimulatorError::NoViableAlt { index, .. } => self.base.no_viable_alternative_error_at(__decision_start, index),
                                _ => self.base.no_viable_alternative_error(__decision_start),
                            })?
                    } else {
                        __prediction
                    }
                };
                self.base.record_generated_prediction_diagnostic(atn(), 114, &__prediction);
                match __prediction.alt {
                    1 => {
                        antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 113isize, self.parse_generated_rule_16_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                    }
                    2 => {
                    }
                    _ => return Err(self.base.no_viable_alternative_error(__decision_start)),
                }
                antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 116isize, self.parse_generated_rule_17_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                self.base.match_token_into(6, 118, atn(), &mut __ctx, &mut __consumed_eof)?;
            }
            success {}
            recovery {}
        }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_16_dispatch(&mut self, precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! { dispatch self, 16, GeneratedRuleError::Fatal; self.parse_generated_rule_16(precedence, allow_fallback) }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_16(&mut self, __precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = __precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! {
            ordinary self, 32isize, 16, allow_fallback, atn(), GeneratedRuleError::Fatal;
            retry [none];
            bind (__ctx, __rule_start, __consumed_eof, __sync_error);
            setup {}
            body {
                self.base.sync_into(atn(), 132, &mut __ctx, false, &mut __sync_error)?;
                let __decision_start = antlr4_runtime::IntStream::index(self.base.input());
                let __prediction = if let Some(__prediction) = self.base.ll1_decision_prediction(atn(), 132) {
                    __prediction
                } else {
                    let __prediction = {
                        let __simulator = self.simulator.get_or_insert_with(|| antlr4_runtime::ParserAtnSimulator::new_shared(atn()));
                        __simulator.adaptive_predict_stream_info_sll_probe(9, 0, self.base.input())
                            .map_err(|__error| match __error {
                                antlr4_runtime::ParserAtnSimulatorError::NoViableAlt { index, .. } => self.base.no_viable_alternative_error_at(__decision_start, index),
                                _ => self.base.no_viable_alternative_error(__decision_start),
                            })?
                    };
                    if __prediction.requires_full_context && self.base.prediction_mode() != antlr4_runtime::PredictionMode::Sll {
                        let __simulator = self.simulator.get_or_insert_with(|| antlr4_runtime::ParserAtnSimulator::new_shared(atn()));
                        let __prediction_context = __simulator.intern_prediction_context(self.base.rule_context_version(), self.base.prediction_context_return_states(atn()));
                        __simulator.set_exact_ambig_detection(self.base.prediction_mode() == antlr4_runtime::PredictionMode::LlExactAmbigDetection);
                        __simulator.adaptive_predict_stream_info_with_context(9, 0, self.base.input(), __prediction_context)
                            .map_err(|__error| match __error {
                                antlr4_runtime::ParserAtnSimulatorError::NoViableAlt { index, .. } => self.base.no_viable_alternative_error_at(__decision_start, index),
                                _ => self.base.no_viable_alternative_error(__decision_start),
                            })?
                    } else {
                        __prediction
                    }
                };
                self.base.record_generated_prediction_diagnostic(atn(), 132, &__prediction);
                match __prediction.alt {
                    1 => {
                        antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 119isize, self.parse_generated_rule_17_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                        antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 120isize, self.parse_generated_rule_9_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                        antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 121isize, self.parse_generated_rule_17_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                        self.base.match_token_into(10, 123, atn(), &mut __ctx, &mut __consumed_eof)?;
                        antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 123isize, self.parse_generated_rule_16_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                        antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 124isize, self.parse_generated_rule_17_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                    }
                    2 => {
                        antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 126isize, self.parse_generated_rule_17_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                        antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 127isize, self.parse_generated_rule_9_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                        antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 128isize, self.parse_generated_rule_17_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                        self.base.sync_into(atn(), 130, &mut __ctx, false, &mut __sync_error)?;
                        let __decision_start = antlr4_runtime::IntStream::index(self.base.input());
                        let __prediction = match self.base.la(1) {
                            10 => antlr4_runtime::ParserAtnPrediction { alt: 1, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                            2..=3 | 6 => antlr4_runtime::ParserAtnPrediction { alt: 2, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                            _ => antlr4_runtime::ParserAtnPrediction { alt: 2, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                        };
                        self.base.record_generated_prediction_diagnostic(atn(), 130, &__prediction);
                        match __prediction.alt {
                            1 => {
                                self.base.match_token_into(10, 131, atn(), &mut __ctx, &mut __consumed_eof)?;
                            }
                            2 => {
                            }
                            _ => return Err(self.base.no_viable_alternative_error(__decision_start)),
                        }
                    }
                    _ => return Err(self.base.no_viable_alternative_error(__decision_start)),
                }
            }
            success {}
            recovery {}
        }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_17_dispatch(&mut self, precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! { dispatch self, 17, GeneratedRuleError::Fatal; self.parse_generated_rule_17(precedence, allow_fallback) }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_17(&mut self, __precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = __precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! {
            ordinary self, 34isize, 17, allow_fallback, atn(), GeneratedRuleError::Fatal;
            retry [none];
            bind (__ctx, __rule_start, __consumed_eof, __sync_error);
            setup {}
            body {
                let mut __loop_iter_140 = false;
                loop {
                    self.base.sync_into(atn(), 140, &mut __ctx, __loop_iter_140, &mut __sync_error)?;
                    let __decision_start = antlr4_runtime::IntStream::index(self.base.input());
                    let __prediction = if let Some(__prediction) = self.base.ll1_decision_prediction(atn(), 140) {
                        __prediction
                    } else {
                        let __prediction = {
                            let __simulator = self.simulator.get_or_insert_with(|| antlr4_runtime::ParserAtnSimulator::new_shared(atn()));
                            __simulator.adaptive_predict_stream_info_sll_probe(11, 0, self.base.input())
                                .map_err(|__error| match __error {
                                    antlr4_runtime::ParserAtnSimulatorError::NoViableAlt { index, .. } => self.base.no_viable_alternative_error_at(__decision_start, index),
                                    _ => self.base.no_viable_alternative_error(__decision_start),
                                })?
                        };
                        if __prediction.requires_full_context && self.base.prediction_mode() != antlr4_runtime::PredictionMode::Sll {
                            let __simulator = self.simulator.get_or_insert_with(|| antlr4_runtime::ParserAtnSimulator::new_shared(atn()));
                            let __prediction_context = __simulator.intern_prediction_context(self.base.rule_context_version(), self.base.prediction_context_return_states(atn()));
                            __simulator.set_exact_ambig_detection(self.base.prediction_mode() == antlr4_runtime::PredictionMode::LlExactAmbigDetection);
                            __simulator.adaptive_predict_stream_info_with_context(11, 0, self.base.input(), __prediction_context)
                                .map_err(|__error| match __error {
                                    antlr4_runtime::ParserAtnSimulatorError::NoViableAlt { index, .. } => self.base.no_viable_alternative_error_at(__decision_start, index),
                                    _ => self.base.no_viable_alternative_error(__decision_start),
                                })?
                        } else {
                            __prediction
                        }
                    };
                    self.base.record_generated_prediction_diagnostic(atn(), 140, &__prediction);
                    match __prediction.alt {
                        1 => {
                            __loop_iter_140 = true;
                            self.base.sync_into(atn(), 135, &mut __ctx, false, &mut __sync_error)?;
                            let __decision_start = antlr4_runtime::IntStream::index(self.base.input());
                            let __prediction = match self.base.la(1) {
                                3 => antlr4_runtime::ParserAtnPrediction { alt: 1, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                                2 => antlr4_runtime::ParserAtnPrediction { alt: 2, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                                _ => return Err(self.base.no_viable_alternative_error(__decision_start)),
                            };
                            self.base.record_generated_prediction_diagnostic(atn(), 135, &__prediction);
                            match __prediction.alt {
                                1 => {
                                    self.base.match_token_into(3, 136, atn(), &mut __ctx, &mut __consumed_eof)?;
                                }
                                2 => {
                                }
                                _ => return Err(self.base.no_viable_alternative_error(__decision_start)),
                            }
                            self.base.match_token_into(2, 139, atn(), &mut __ctx, &mut __consumed_eof)?;
                        }
                        2 => {
                            break;
                        }
                        _ => return Err(self.base.no_viable_alternative_error(__decision_start)),
                    }
                }
            }
            success {}
            recovery {}
        }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_18_dispatch(&mut self, precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! { dispatch self, 18, GeneratedRuleError::Fatal; self.parse_generated_rule_18(precedence, allow_fallback) }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_18(&mut self, __precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = __precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! {
            ordinary self, 36isize, 18, allow_fallback, atn(), GeneratedRuleError::Fatal;
            retry [none];
            bind (__ctx, __rule_start, __consumed_eof, __sync_error);
            setup {}
            body {
                let mut __decision_start = antlr4_runtime::IntStream::index(self.base.input());
                let __prediction = match self.base.la(1) {
                    4 => antlr4_runtime::ParserAtnPrediction { alt: 1, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                    5 => antlr4_runtime::ParserAtnPrediction { alt: 2, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                    _ => {
                        self.base.sync_into(atn(), 145, &mut __ctx, false, &mut __sync_error)?;
                        __decision_start = antlr4_runtime::IntStream::index(self.base.input());
                        match self.base.la(1) {
                            4 => antlr4_runtime::ParserAtnPrediction { alt: 1, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                            5 => antlr4_runtime::ParserAtnPrediction { alt: 2, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                            _ => return Err(self.base.no_viable_alternative_error(__decision_start)),
                        }
                    }
                };
                self.base.record_generated_prediction_diagnostic(atn(), 145, &__prediction);
                match __prediction.alt {
                    1 => {
                        antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 143isize, self.parse_generated_rule_19_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                    }
                    2 => {
                        antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 144isize, self.parse_generated_rule_23_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                    }
                    _ => return Err(self.base.no_viable_alternative_error(__decision_start)),
                }
            }
            success {}
            recovery {}
        }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_19_dispatch(&mut self, precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! { dispatch self, 19, GeneratedRuleError::Fatal; self.parse_generated_rule_19(precedence, allow_fallback) }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_19(&mut self, __precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = __precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! {
            ordinary self, 38isize, 19, allow_fallback, atn(), GeneratedRuleError::Fatal;
            retry [none];
            bind (__ctx, __rule_start, __consumed_eof, __sync_error);
            setup {}
            body {
                self.base.match_token_into(4, 148, atn(), &mut __ctx, &mut __consumed_eof)?;
                antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 148isize, self.parse_generated_rule_4_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                self.base.match_token_into(6, 150, atn(), &mut __ctx, &mut __consumed_eof)?;
            }
            success {}
            recovery {}
        }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_20_dispatch(&mut self, precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! { dispatch self, 20, GeneratedRuleError::Fatal; self.parse_generated_rule_20(precedence, allow_fallback) }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_20(&mut self, __precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = __precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! {
            ordinary self, 40isize, 20, allow_fallback, atn(), GeneratedRuleError::Fatal;
            retry [none];
            bind (__ctx, __rule_start, __consumed_eof, __sync_error);
            setup {}
            body {
                self.base.match_token_into(15, 152, atn(), &mut __ctx, &mut __consumed_eof)?;
                antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 152isize, self.parse_generated_rule_17_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 153isize, self.parse_generated_rule_21_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 154isize, self.parse_generated_rule_17_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                self.base.match_token_into(31, 156, atn(), &mut __ctx, &mut __consumed_eof)?;
            }
            success {}
            recovery {}
        }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_21_dispatch(&mut self, precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! { dispatch self, 21, GeneratedRuleError::Fatal; self.parse_generated_rule_21(precedence, allow_fallback) }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_21(&mut self, __precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = __precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! {
            ordinary self, 42isize, 21, allow_fallback, atn(), GeneratedRuleError::Fatal;
            retry [none];
            bind (__ctx, __rule_start, __consumed_eof, __sync_error);
            setup {}
            body {
                self.base.sync_into(atn(), 158, &mut __ctx, false, &mut __sync_error)?;
                let __decision_start = antlr4_runtime::IntStream::index(self.base.input());
                let __prediction = match self.base.la(1) {
                    11..=13 => antlr4_runtime::ParserAtnPrediction { alt: 1, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                    2..=3 | 31 => antlr4_runtime::ParserAtnPrediction { alt: 2, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                    _ => antlr4_runtime::ParserAtnPrediction { alt: 2, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                };
                self.base.record_generated_prediction_diagnostic(atn(), 158, &__prediction);
                match __prediction.alt {
                    1 => {
                        antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 157isize, self.parse_generated_rule_22_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                    }
                    2 => {
                    }
                    _ => return Err(self.base.no_viable_alternative_error(__decision_start)),
                }
            }
            success {}
            recovery {}
        }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_22_dispatch(&mut self, precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! { dispatch self, 22, GeneratedRuleError::Fatal; self.parse_generated_rule_22(precedence, allow_fallback) }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_22(&mut self, __precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = __precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! {
            ordinary self, 44isize, 22, allow_fallback, atn(), GeneratedRuleError::Fatal;
            retry [none];
            bind (__ctx, __rule_start, __consumed_eof, __sync_error);
            setup {}
            body {
                antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 160isize, self.parse_generated_rule_4_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                self.base.match_token_into(8, 162, atn(), &mut __ctx, &mut __consumed_eof)?;
                antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 162isize, self.parse_generated_rule_9_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 163isize, self.parse_generated_rule_17_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                self.base.sync_into(atn(), 169, &mut __ctx, false, &mut __sync_error)?;
                let __decision_start = antlr4_runtime::IntStream::index(self.base.input());
                let __prediction = match self.base.la(1) {
                    10 => antlr4_runtime::ParserAtnPrediction { alt: 1, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                    2..=3 | 31 => antlr4_runtime::ParserAtnPrediction { alt: 2, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                    _ => antlr4_runtime::ParserAtnPrediction { alt: 2, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                };
                self.base.record_generated_prediction_diagnostic(atn(), 169, &__prediction);
                match __prediction.alt {
                    1 => {
                        self.base.match_token_into(10, 165, atn(), &mut __ctx, &mut __consumed_eof)?;
                        antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 165isize, self.parse_generated_rule_17_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                        self.base.sync_into(atn(), 167, &mut __ctx, false, &mut __sync_error)?;
                        let __decision_start = antlr4_runtime::IntStream::index(self.base.input());
                        let __prediction = match self.base.la(1) {
                            11..=13 => antlr4_runtime::ParserAtnPrediction { alt: 1, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                            2..=3 | 31 => antlr4_runtime::ParserAtnPrediction { alt: 2, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                            _ => antlr4_runtime::ParserAtnPrediction { alt: 2, requires_full_context: false, has_semantic_context: false, diagnostic: None },
                        };
                        self.base.record_generated_prediction_diagnostic(atn(), 167, &__prediction);
                        match __prediction.alt {
                            1 => {
                                antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 166isize, self.parse_generated_rule_22_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                            }
                            2 => {
                            }
                            _ => return Err(self.base.no_viable_alternative_error(__decision_start)),
                        }
                    }
                    2 => {
                    }
                    _ => return Err(self.base.no_viable_alternative_error(__decision_start)),
                }
            }
            success {}
            recovery {}
        }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_23_dispatch(&mut self, precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! { dispatch self, 23, GeneratedRuleError::Fatal; self.parse_generated_rule_23(precedence, allow_fallback) }
    }

    #[allow(dead_code)]
    fn parse_generated_rule_23(&mut self, __precedence: i32, allow_fallback: bool) -> Result<antlr4_runtime::ParseTree, GeneratedRuleError> {
        let _ = __precedence;
        antlr4_runtime::__antlr4_rust_generated_rule! {
            ordinary self, 46isize, 23, allow_fallback, atn(), GeneratedRuleError::Fatal;
            retry [none];
            bind (__ctx, __rule_start, __consumed_eof, __sync_error);
            setup {}
            body {
                self.base.match_token_into(5, 172, atn(), &mut __ctx, &mut __consumed_eof)?;
                antlr4_runtime::__antlr4_rust_invoke_subrule!(self, 172isize, self.parse_generated_rule_4_dispatch(0, false).map_err(GeneratedRuleError::into_error), __ctx);
                self.base.match_token_into(7, 174, atn(), &mut __ctx, &mut __consumed_eof)?;
            }
            success {}
            recovery {}
        }
    }



    pub fn document(&mut self) -> Result<antlr4_runtime::ParseTree, antlr4_runtime::AntlrError> {
        self.parse_rule(0)
    }
    pub fn expression(&mut self) -> Result<antlr4_runtime::ParseTree, antlr4_runtime::AntlrError> {
        self.parse_rule(1)
    }
    pub fn comment(&mut self) -> Result<antlr4_runtime::ParseTree, antlr4_runtime::AntlrError> {
        self.parse_rule(2)
    }
    pub fn key_value(&mut self) -> Result<antlr4_runtime::ParseTree, antlr4_runtime::AntlrError> {
        self.parse_rule(3)
    }
    pub fn key(&mut self) -> Result<antlr4_runtime::ParseTree, antlr4_runtime::AntlrError> {
        self.parse_rule(4)
    }
    pub fn simple_key(&mut self) -> Result<antlr4_runtime::ParseTree, antlr4_runtime::AntlrError> {
        self.parse_rule(5)
    }
    pub fn unquoted_key(&mut self) -> Result<antlr4_runtime::ParseTree, antlr4_runtime::AntlrError> {
        self.parse_rule(6)
    }
    pub fn quoted_key(&mut self) -> Result<antlr4_runtime::ParseTree, antlr4_runtime::AntlrError> {
        self.parse_rule(7)
    }
    pub fn dotted_key(&mut self) -> Result<antlr4_runtime::ParseTree, antlr4_runtime::AntlrError> {
        self.parse_rule(8)
    }
    pub fn value(&mut self) -> Result<antlr4_runtime::ParseTree, antlr4_runtime::AntlrError> {
        self.parse_rule(9)
    }
    pub fn string(&mut self) -> Result<antlr4_runtime::ParseTree, antlr4_runtime::AntlrError> {
        self.parse_rule(10)
    }
    pub fn integer(&mut self) -> Result<antlr4_runtime::ParseTree, antlr4_runtime::AntlrError> {
        self.parse_rule(11)
    }
    pub fn floating_point(&mut self) -> Result<antlr4_runtime::ParseTree, antlr4_runtime::AntlrError> {
        self.parse_rule(12)
    }
    pub fn bool(&mut self) -> Result<antlr4_runtime::ParseTree, antlr4_runtime::AntlrError> {
        self.parse_rule(13)
    }
    pub fn date_time(&mut self) -> Result<antlr4_runtime::ParseTree, antlr4_runtime::AntlrError> {
        self.parse_rule(14)
    }
    pub fn array(&mut self) -> Result<antlr4_runtime::ParseTree, antlr4_runtime::AntlrError> {
        self.parse_rule(15)
    }
    pub fn array_values(&mut self) -> Result<antlr4_runtime::ParseTree, antlr4_runtime::AntlrError> {
        self.parse_rule(16)
    }
    pub fn comment_or_nl(&mut self) -> Result<antlr4_runtime::ParseTree, antlr4_runtime::AntlrError> {
        self.parse_rule(17)
    }
    pub fn table(&mut self) -> Result<antlr4_runtime::ParseTree, antlr4_runtime::AntlrError> {
        self.parse_rule(18)
    }
    pub fn standard_table(&mut self) -> Result<antlr4_runtime::ParseTree, antlr4_runtime::AntlrError> {
        self.parse_rule(19)
    }
    pub fn inline_table(&mut self) -> Result<antlr4_runtime::ParseTree, antlr4_runtime::AntlrError> {
        self.parse_rule(20)
    }
    pub fn inline_table_keyvals(&mut self) -> Result<antlr4_runtime::ParseTree, antlr4_runtime::AntlrError> {
        self.parse_rule(21)
    }
    pub fn inline_table_keyvals_non_empty(&mut self) -> Result<antlr4_runtime::ParseTree, antlr4_runtime::AntlrError> {
        self.parse_rule(22)
    }
    pub fn array_table(&mut self) -> Result<antlr4_runtime::ParseTree, antlr4_runtime::AntlrError> {
        self.parse_rule(23)
    }


    fn run_action(&mut self, _action: antlr4_runtime::ParserAction, _tree: antlr4_runtime::ParseTree) {}

}



antlr4_runtime::__antlr4_rust_parser_facade! {
    type: TomlParser<L, H>,
    fields: {
        base: base,
        simulator: simulator,
        generated_only: generated_only,
    },
    metadata: metadata,
    parser_atn: parser_atn,
    reset(parser) {
    }
}
}

#[allow(warnings, missing_docs, clippy::all, clippy::pedantic, clippy::nursery)]
pub use self::__antlr4_rust_generated::*;
