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
53impl From<Preproc> for &'static str {
54    #[inline]
55    fn from(tok: Preproc) -> Self {
56        match tok {
57            Preproc::End => "end",
58            Preproc::Identifier => "identifier",
59            Preproc::Nothing => "nothing",
60            Preproc::PreprocContinuationLine => "preproc_continuation_line",
61            Preproc::PreprocLine => "preproc_line",
62            Preproc::PreprocIncludeToken1 => "preproc_include_token1",
63            Preproc::LT => "<",
64            Preproc::GT => ">",
65            Preproc::Path => "path",
66            Preproc::DefineToken1 => "define_token1",
67            Preproc::LF => "\n",
68            Preproc::PreprocIfToken1 => "preproc_if_token1",
69            Preproc::PreprocIfToken2 => "preproc_if_token2",
70            Preproc::PreprocElifToken1 => "preproc_elif_token1",
71            Preproc::PreprocElseToken1 => "preproc_else_token1",
72            Preproc::UndefToken1 => "undef_token1",
73            Preproc::PreprocNothingToken1 => "preproc_nothing_token1",
74            Preproc::StringLiteralToken1 => "string_literal_token1",
75            Preproc::CharLiteralToken1 => "char_literal_token1",
76            Preproc::IntegerLiteral => "integer_literal",
77            Preproc::Comment => "comment",
78            Preproc::RawStringLiteral => "raw_string_literal",
79            Preproc::TranslationUnit => "translation_unit",
80            Preproc::TopLevelItem => "_top_level_item",
81            Preproc::PreprocInclude => "preproc_include",
82            Preproc::Define => "define",
83            Preproc::PreprocIf => "preproc_if",
84            Preproc::PreprocElif => "preproc_elif",
85            Preproc::PreprocElse => "preproc_else",
86            Preproc::Undef => "undef",
87            Preproc::PreprocNothing => "preproc_nothing",
88            Preproc::StringLiteral => "string_literal",
89            Preproc::CharLiteral => "char_literal",
90            Preproc::TranslationUnitRepeat1 => "translation_unit_repeat1",
91            Preproc::DefineRepeat1 => "define_repeat1",
92            Preproc::PreprocIfRepeat1 => "preproc_if_repeat1",
93            Preproc::Error => "ERROR",
94        }
95    }
96}
97
98impl From<u16> for Preproc {
99    #[inline]
100    fn from(x: u16) -> Self {
101        num_traits::FromPrimitive::from_u16(x).unwrap_or(Self::Error)
102    }
103}
104
105// Preproc == u16
106impl PartialEq<u16> for Preproc {
107    #[inline]
108    fn eq(&self, x: &u16) -> bool {
109        *self == Into::<Self>::into(*x)
110    }
111}
112
113// u16 == Preproc
114impl PartialEq<Preproc> for u16 {
115    #[inline]
116    fn eq(&self, x: &Preproc) -> bool {
117        *x == *self
118    }
119}