Skip to main content

shuck_ast/
tokens.rs

1/// Cheap token classification for parser dispatch.
2#[repr(u8)]
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
4pub enum TokenKind {
5    Word,
6    LiteralWord,
7    QuotedWord,
8    Comment,
9    Newline,
10    Semicolon,
11    DoubleSemicolon,
12    SemiAmp,
13    DoubleSemiAmp,
14    SemiPipe,
15    Pipe,
16    PipeBoth,
17    And,
18    Or,
19    Background,
20    BackgroundPipe,
21    BackgroundBang,
22    RedirectOut,
23    RedirectAppend,
24    RedirectIn,
25    RedirectReadWrite,
26    HereDoc,
27    HereDocStrip,
28    HereString,
29    LeftParen,
30    RightParen,
31    DoubleLeftParen,
32    DoubleRightParen,
33    LeftBrace,
34    RightBrace,
35    DoubleLeftBracket,
36    DoubleRightBracket,
37    Assignment,
38    ProcessSubIn,
39    ProcessSubOut,
40    RedirectBoth,
41    RedirectBothAppend,
42    Clobber,
43    DupOutput,
44    DupInput,
45    RedirectFd,
46    RedirectFdAppend,
47    DupFd,
48    DupFdIn,
49    DupFdClose,
50    RedirectFdIn,
51    RedirectFdReadWrite,
52    Error,
53}
54
55impl TokenKind {
56    pub const fn is_word_like(self) -> bool {
57        matches!(self, Self::Word | Self::LiteralWord | Self::QuotedWord)
58    }
59}