big_code_analysis_ast/languages/
language_ccomment.rs1#![allow(clippy::match_same_arms, clippy::too_many_lines)]
4#![allow(missing_docs)]
7
8use num_derive::FromPrimitive;
11
12#[derive(Clone, Debug, PartialEq, Eq, FromPrimitive)]
13pub enum Ccomment {
14 End = 0,
15 Nothing = 1,
16 PreprocContinuationLine = 2,
17 PreprocLine = 3,
18 DefineToken1 = 4,
19 StringLiteralToken1 = 5,
20 CharLiteralToken1 = 6,
21 Comment = 7,
22 RawStringLiteral = 8,
23 TranslationUnit = 9,
24 TopLevelItem = 10,
25 Define = 11,
26 StringLiteral = 12,
27 CharLiteral = 13,
28 TranslationUnitRepeat1 = 14,
29 DefineRepeat1 = 15,
30 Error = 16,
31}
32
33pub const CCOMMENT_KIND_FLAGS: &[(u16, bool, bool)] = &[
38 (0, false, false),
39 (1, true, true),
40 (2, true, true),
41 (3, true, true),
42 (4, false, false),
43 (5, false, false),
44 (6, false, false),
45 (7, true, true),
46 (8, true, true),
47 (9, true, true),
48 (10, false, false),
49 (11, true, true),
50 (12, true, true),
51 (13, true, true),
52 (14, false, false),
53 (15, false, false),
54];
55
56impl From<Ccomment> for &'static str {
57 #[inline]
58 fn from(tok: Ccomment) -> Self {
59 match tok {
60 Ccomment::End => "end",
61 Ccomment::Nothing => "nothing",
62 Ccomment::PreprocContinuationLine => "preproc_continuation_line",
63 Ccomment::PreprocLine => "preproc_line",
64 Ccomment::DefineToken1 => "define_token1",
65 Ccomment::StringLiteralToken1 => "string_literal_token1",
66 Ccomment::CharLiteralToken1 => "char_literal_token1",
67 Ccomment::Comment => "comment",
68 Ccomment::RawStringLiteral => "raw_string_literal",
69 Ccomment::TranslationUnit => "translation_unit",
70 Ccomment::TopLevelItem => "_top_level_item",
71 Ccomment::Define => "define",
72 Ccomment::StringLiteral => "string_literal",
73 Ccomment::CharLiteral => "char_literal",
74 Ccomment::TranslationUnitRepeat1 => "translation_unit_repeat1",
75 Ccomment::DefineRepeat1 => "define_repeat1",
76 Ccomment::Error => "ERROR",
77 }
78 }
79}
80
81impl From<u16> for Ccomment {
82 #[inline]
83 fn from(x: u16) -> Self {
84 num_traits::FromPrimitive::from_u16(x).unwrap_or(Self::Error)
85 }
86}
87
88impl PartialEq<u16> for Ccomment {
90 #[inline]
91 fn eq(&self, x: &u16) -> bool {
92 *self == Into::<Self>::into(*x)
93 }
94}
95
96impl PartialEq<Ccomment> for u16 {
98 #[inline]
99 fn eq(&self, x: &Ccomment) -> bool {
100 *x == *self
101 }
102}