Skip to main content

big_code_analysis_ast/languages/
language_preproc.rs

1// See `src/languages/mod.rs` for the rationale behind the per-file
2// pedantic carve-outs below.
3#![allow(clippy::match_same_arms, clippy::too_many_lines)]
4// One variant per grammar kind id, named after the rule; the name is
5// the documentation and there is nothing per-variant to add.
6#![allow(missing_docs)]
7
8// Code generated; DO NOT EDIT.
9
10use num_derive::FromPrimitive;
11
12#[derive(Clone, Debug, PartialEq, Eq, FromPrimitive)]
13pub enum Preproc {
14    End = 0,
15    Identifier = 1,
16    Nothing = 2,
17    PreprocContinuationLine = 3,
18    PreprocLine = 4,
19    PreprocIncludeToken1 = 5,
20    LT = 6,
21    GT = 7,
22    Path = 8,
23    DefineToken1 = 9,
24    LF = 10,
25    PreprocIfToken1 = 11,
26    PreprocIfToken2 = 12,
27    PreprocElifToken1 = 13,
28    PreprocElseToken1 = 14,
29    UndefToken1 = 15,
30    PreprocNothingToken1 = 16,
31    StringLiteralToken1 = 17,
32    CharLiteralToken1 = 18,
33    IntegerLiteral = 19,
34    Comment = 20,
35    RawStringLiteral = 21,
36    TranslationUnit = 22,
37    TopLevelItem = 23,
38    PreprocInclude = 24,
39    Define = 25,
40    PreprocIf = 26,
41    PreprocElif = 27,
42    PreprocElse = 28,
43    Undef = 29,
44    PreprocNothing = 30,
45    StringLiteral = 31,
46    CharLiteral = 32,
47    TranslationUnitRepeat1 = 33,
48    DefineRepeat1 = 34,
49    PreprocIfRepeat1 = 35,
50    Error = 36,
51}
52
53/// Each runtime kind id of `Preproc` with tree-sitter's `named` and
54/// `visible` flags, in id order. A label for the id the enum identifies,
55/// read by the role-coverage gate; the generator's ERROR sentinel has no
56/// entry.
57pub const PREPROC_KIND_FLAGS: &[(u16, bool, bool)] = &[
58    (0, false, false),
59    (1, true, true),
60    (2, true, true),
61    (3, true, true),
62    (4, true, true),
63    (5, false, false),
64    (6, false, true),
65    (7, false, true),
66    (8, true, true),
67    (9, false, false),
68    (10, false, true),
69    (11, false, false),
70    (12, false, false),
71    (13, false, false),
72    (14, false, false),
73    (15, false, false),
74    (16, false, false),
75    (17, false, false),
76    (18, false, false),
77    (19, true, true),
78    (20, true, true),
79    (21, true, true),
80    (22, true, true),
81    (23, false, false),
82    (24, true, true),
83    (25, true, true),
84    (26, true, true),
85    (27, true, true),
86    (28, true, true),
87    (29, true, true),
88    (30, true, true),
89    (31, true, true),
90    (32, true, true),
91    (33, false, false),
92    (34, false, false),
93    (35, false, false),
94];
95
96impl From<Preproc> for &'static str {
97    #[inline]
98    fn from(tok: Preproc) -> Self {
99        match tok {
100            Preproc::End => "end",
101            Preproc::Identifier => "identifier",
102            Preproc::Nothing => "nothing",
103            Preproc::PreprocContinuationLine => "preproc_continuation_line",
104            Preproc::PreprocLine => "preproc_line",
105            Preproc::PreprocIncludeToken1 => "preproc_include_token1",
106            Preproc::LT => "<",
107            Preproc::GT => ">",
108            Preproc::Path => "path",
109            Preproc::DefineToken1 => "define_token1",
110            Preproc::LF => "\n",
111            Preproc::PreprocIfToken1 => "preproc_if_token1",
112            Preproc::PreprocIfToken2 => "preproc_if_token2",
113            Preproc::PreprocElifToken1 => "preproc_elif_token1",
114            Preproc::PreprocElseToken1 => "preproc_else_token1",
115            Preproc::UndefToken1 => "undef_token1",
116            Preproc::PreprocNothingToken1 => "preproc_nothing_token1",
117            Preproc::StringLiteralToken1 => "string_literal_token1",
118            Preproc::CharLiteralToken1 => "char_literal_token1",
119            Preproc::IntegerLiteral => "integer_literal",
120            Preproc::Comment => "comment",
121            Preproc::RawStringLiteral => "raw_string_literal",
122            Preproc::TranslationUnit => "translation_unit",
123            Preproc::TopLevelItem => "_top_level_item",
124            Preproc::PreprocInclude => "preproc_include",
125            Preproc::Define => "define",
126            Preproc::PreprocIf => "preproc_if",
127            Preproc::PreprocElif => "preproc_elif",
128            Preproc::PreprocElse => "preproc_else",
129            Preproc::Undef => "undef",
130            Preproc::PreprocNothing => "preproc_nothing",
131            Preproc::StringLiteral => "string_literal",
132            Preproc::CharLiteral => "char_literal",
133            Preproc::TranslationUnitRepeat1 => "translation_unit_repeat1",
134            Preproc::DefineRepeat1 => "define_repeat1",
135            Preproc::PreprocIfRepeat1 => "preproc_if_repeat1",
136            Preproc::Error => "ERROR",
137        }
138    }
139}
140
141impl From<u16> for Preproc {
142    #[inline]
143    fn from(x: u16) -> Self {
144        num_traits::FromPrimitive::from_u16(x).unwrap_or(Self::Error)
145    }
146}
147
148// Preproc == u16
149impl PartialEq<u16> for Preproc {
150    #[inline]
151    fn eq(&self, x: &u16) -> bool {
152        *self == Into::<Self>::into(*x)
153    }
154}
155
156// u16 == Preproc
157impl PartialEq<Preproc> for u16 {
158    #[inline]
159    fn eq(&self, x: &Preproc) -> bool {
160        *x == *self
161    }
162}