slang_solidity 1.3.2

A modular set of compiler APIs empowering the next generation of Solidity code analysis and developer tooling. Written in Rust and distributed in multiple languages.
Documentation
{# This needs to stay in sync with the wit-bindgen output #}
/// Represents different kinds of terminal nodes in the syntax tree.
/// These are leaf nodes that represent actual tokens in the source code.
#[derive(
    Debug,
    Eq,
    Hash,
    Ord,
    PartialEq,
    PartialOrd,
    serde::Serialize,
    strum_macros::AsRefStr,
    strum_macros::Display,
    strum_macros::EnumString,
    strum_macros::IntoStaticStr,
)]
#[derive(Clone, Copy)] 
#[allow(clippy::upper_case_acronyms)]
#[allow(clippy::doc_markdown)]
#[allow(clippy::doc_link_with_quotes)]
{%- if model.kinds.terminal_kinds|length <= 256 %} #[repr(u8)] {% else %} #[repr(u16)] {% endif %}
pub enum TerminalKind {
    {# Built-in: #}
    /// This terminal is created when the parser encounters an unexpected part of the input,
    /// and it cannot recognize it as any valid syntax in this position in the grammar.
    UNRECOGNIZED,
    /// This terminal is created when the parser is expecting a certain terminal but does not find it.
    /// Adding the missing input in this position may allow the parser to produce a valid tree there.
    MISSING,

    {# Generated: #}
    {%- for variant in model.kinds.terminal_kinds -%}
        /// Represents a node with kind `{{ variant.id }}`, having the following structure:
        ///
        /// ```ebnf
        {%- for line in variant.documentation | split(pat="\n") %}
        /// {{ line }}
        {%- endfor %}
        /// ```
        {{ variant.id }},
    {%- endfor -%}
}

impl crate::cst::TerminalKindExtensions for TerminalKind {
    fn is_identifier(self) -> bool {
        matches!(
            self,
            {%- for variant in model.kinds.identifier_terminals -%}
                | Self::{{ variant }}
            {%- endfor -%}
        )
    }

    fn is_trivia(self) -> bool {
        matches!(
            self,
            {%- for variant in model.kinds.trivia_terminals -%}
                | Self::{{ variant }}
            {%- endfor -%}
        )
    }

    fn is_valid(self) -> bool {
        !matches!(self, Self::UNRECOGNIZED | Self::MISSING)
    }
}