summaryrefslogtreecommitdiffstats
path: root/third_party/rust/jsparagus-generated-parser/src/declaration_kind.rs
blob: 7771d7f5f33fa6c79985dff6c2ac33aa716d2fb8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// The kind of declaration.
//
// This is used for error reporting and also for handling early error check.
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum DeclarationKind {
    FormalParameter,

    Var,
    Let,
    Const,

    Class,

    Import,

    BodyLevelFunction,

    LexicalFunction,
    LexicalAsyncOrGenerator,

    // This is used after parsing the entire function/script body.
    VarForAnnexBLexicalFunction,

    CatchParameter,
}

impl DeclarationKind {
    pub fn to_str(&self) -> &'static str {
        match self {
            Self::FormalParameter => "formal parameter",
            Self::Var => "var",
            Self::Let => "let",
            Self::Const => "const",
            Self::Class => "class",
            Self::Import => "import",
            Self::BodyLevelFunction => "function",
            Self::LexicalFunction => "function",
            Self::LexicalAsyncOrGenerator => "function",
            Self::VarForAnnexBLexicalFunction => "function",
            Self::CatchParameter => "catch parameter",
        }
    }
}