Using TypePal for context-aware typing

35 Views Asked by At

I tried using the TypePal collect function like so:

...
// Modules
void collect(current: (Module)`module <Ident moduleName>{<ModuleBody moduleBody>}`, Collector c){
    c.define("<moduleName>", moduleId(), current, defType(moduleType()));
    c.enterScope(current);
    {
        collect(moduleBody, c);
    } 
    c.leaveScope(current);
}


void collect(current:
    (ModuleBody)`<Declaration* _>
                'defmacro <Ident macroDefName> ( <{Param ","}* params> ) { <MacroBody macroBody>}
                '<Declaration* _>`
    , Collector c
){
    c.define("<macroDefName>", macroDefId(), current, defType(macroDef(macroBody)));
}

void collect(current: (Declaration)`defmacro <Ident macroDefName> ( <{Param ","}* params> ) { <MacroBody macroBody>}`, Collector c){
    c.define("<macroDefName>", macroDefId(), current, defType(macroDef(macroBody)));
}


// simple implementation
void collect(
    current:
    (ModuleBody)`<Declaration* _>
                '<Ident name>!(<{Expr ","}* args>)
                '<Declaration* _>`
    , Collector c
){
    c.use(name, {macroDefId()});
}

...

but it doesn't seem to work well, could it because I used the context-based pattern and it doesn't work well with the collect function?

0

There are 0 best solutions below