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
use crate::parser::Parser;
use crate::syntax::entity::ParsedEntity;
use lark_entity::Entity;
use lark_error::ErrorReported;
use lark_span::FileName;
use lark_span::Spanned;
use lark_string::GlobalIdentifier;

crate mod function_declaration;
crate mod struct_declaration;

crate trait EntityMacroDefinition: Send {
    /// Invoked when the macro name has been recognized and
    /// consumed. Has the job of parsing the rest of the entity (using
    /// the helper methods on `parser` to do so) and ultimately
    /// returning the entity structure.
    fn expect(
        &self,
        // The parser we can use to extract next token and so forth.
        parser: &mut Parser<'_>,

        // The base entity that this is a subentity of. Needed to
        // create a `lark_entity::Entity`.
        base: Entity,

        // The macro name we were invoked with (and the span). Note
        // that the "start" of this span will also be the start of
        // our entity's span.
        macro_name: Spanned<GlobalIdentifier, FileName>,
    ) -> Result<ParsedEntity, ErrorReported>;
}