big-code-analysis-ast 2.6.0

Parse and classification layer behind big-code-analysis (internal, version-locked)
Documentation
// See `src/languages/mod.rs` for the rationale behind the per-file
// pedantic carve-outs below.
#![allow(clippy::match_same_arms, clippy::too_many_lines)]
// One variant per grammar kind id, named after the rule; the name is
// the documentation and there is nothing per-variant to add.
#![allow(missing_docs)]

// Code generated; DO NOT EDIT.

use num_derive::FromPrimitive;

#[derive(Clone, Debug, PartialEq, Eq, FromPrimitive)]
pub enum Preproc {
    End = 0,
    Identifier = 1,
    Nothing = 2,
    PreprocContinuationLine = 3,
    PreprocLine = 4,
    PreprocIncludeToken1 = 5,
    LT = 6,
    GT = 7,
    Path = 8,
    DefineToken1 = 9,
    LF = 10,
    PreprocIfToken1 = 11,
    PreprocIfToken2 = 12,
    PreprocElifToken1 = 13,
    PreprocElseToken1 = 14,
    UndefToken1 = 15,
    PreprocNothingToken1 = 16,
    StringLiteralToken1 = 17,
    CharLiteralToken1 = 18,
    IntegerLiteral = 19,
    Comment = 20,
    RawStringLiteral = 21,
    TranslationUnit = 22,
    TopLevelItem = 23,
    PreprocInclude = 24,
    Define = 25,
    PreprocIf = 26,
    PreprocElif = 27,
    PreprocElse = 28,
    Undef = 29,
    PreprocNothing = 30,
    StringLiteral = 31,
    CharLiteral = 32,
    TranslationUnitRepeat1 = 33,
    DefineRepeat1 = 34,
    PreprocIfRepeat1 = 35,
    Error = 36,
}

/// Each runtime kind id of `Preproc` with tree-sitter's `named` and
/// `visible` flags, in id order. A label for the id the enum identifies,
/// read by the role-coverage gate; the generator's ERROR sentinel has no
/// entry.
pub const PREPROC_KIND_FLAGS: &[(u16, bool, bool)] = &[
    (0, false, false),
    (1, true, true),
    (2, true, true),
    (3, true, true),
    (4, true, true),
    (5, false, false),
    (6, false, true),
    (7, false, true),
    (8, true, true),
    (9, false, false),
    (10, false, true),
    (11, false, false),
    (12, false, false),
    (13, false, false),
    (14, false, false),
    (15, false, false),
    (16, false, false),
    (17, false, false),
    (18, false, false),
    (19, true, true),
    (20, true, true),
    (21, true, true),
    (22, true, true),
    (23, false, false),
    (24, true, true),
    (25, true, true),
    (26, true, true),
    (27, true, true),
    (28, true, true),
    (29, true, true),
    (30, true, true),
    (31, true, true),
    (32, true, true),
    (33, false, false),
    (34, false, false),
    (35, false, false),
];

impl From<Preproc> for &'static str {
    #[inline]
    fn from(tok: Preproc) -> Self {
        match tok {
            Preproc::End => "end",
            Preproc::Identifier => "identifier",
            Preproc::Nothing => "nothing",
            Preproc::PreprocContinuationLine => "preproc_continuation_line",
            Preproc::PreprocLine => "preproc_line",
            Preproc::PreprocIncludeToken1 => "preproc_include_token1",
            Preproc::LT => "<",
            Preproc::GT => ">",
            Preproc::Path => "path",
            Preproc::DefineToken1 => "define_token1",
            Preproc::LF => "\n",
            Preproc::PreprocIfToken1 => "preproc_if_token1",
            Preproc::PreprocIfToken2 => "preproc_if_token2",
            Preproc::PreprocElifToken1 => "preproc_elif_token1",
            Preproc::PreprocElseToken1 => "preproc_else_token1",
            Preproc::UndefToken1 => "undef_token1",
            Preproc::PreprocNothingToken1 => "preproc_nothing_token1",
            Preproc::StringLiteralToken1 => "string_literal_token1",
            Preproc::CharLiteralToken1 => "char_literal_token1",
            Preproc::IntegerLiteral => "integer_literal",
            Preproc::Comment => "comment",
            Preproc::RawStringLiteral => "raw_string_literal",
            Preproc::TranslationUnit => "translation_unit",
            Preproc::TopLevelItem => "_top_level_item",
            Preproc::PreprocInclude => "preproc_include",
            Preproc::Define => "define",
            Preproc::PreprocIf => "preproc_if",
            Preproc::PreprocElif => "preproc_elif",
            Preproc::PreprocElse => "preproc_else",
            Preproc::Undef => "undef",
            Preproc::PreprocNothing => "preproc_nothing",
            Preproc::StringLiteral => "string_literal",
            Preproc::CharLiteral => "char_literal",
            Preproc::TranslationUnitRepeat1 => "translation_unit_repeat1",
            Preproc::DefineRepeat1 => "define_repeat1",
            Preproc::PreprocIfRepeat1 => "preproc_if_repeat1",
            Preproc::Error => "ERROR",
        }
    }
}

impl From<u16> for Preproc {
    #[inline]
    fn from(x: u16) -> Self {
        num_traits::FromPrimitive::from_u16(x).unwrap_or(Self::Error)
    }
}

// Preproc == u16
impl PartialEq<u16> for Preproc {
    #[inline]
    fn eq(&self, x: &u16) -> bool {
        *self == Into::<Self>::into(*x)
    }
}

// u16 == Preproc
impl PartialEq<Preproc> for u16 {
    #[inline]
    fn eq(&self, x: &Preproc) -> bool {
        *x == *self
    }
}