~starkingdoms/starkingdoms

ref: 6922bff15844056844e1d738494ed7b70def1fef starkingdoms/kabel/src/macros.rs -rw-r--r-- 670 bytes
6922bff1 — ghostlyzsh call, member access, declaration, and assignment 1 year, 4 months ago
                                                                                
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
#[macro_export]
macro_rules! token {
    ($self:expr, $token:expr) => {
        crate::lexer::Token {
            line: $self.line,
            line_start: $self.line_start,
            column: $self.column,
            start: $self.start,
            end: $self.current,
            token_type: $token,
        }
    };
}

#[macro_export]
macro_rules! lit {
    ($type:ident, $data:expr, $token:expr) => {
        $crate::parser::AST {
            ast_type: $crate::parser::ASTType::Lit($crate::parser::Lit::$type($data)),
            start: $token.start,
            end: $token.end,
            line: $token.line,
            column: $token.column,
        }
    }
}