javascript - Local variable between inner macro calls -


i'm trying create pair of sweet js macros inner , outer macro share local variable:

syntax cdo = function(ctx) {     let call = ctx.next().value;     let dummy = #`dummy`.get(0);     let context_id = #`${dummy.fromidentifier("$context$")}`;     return #`let ${context_id} = ${call}`; }  syntax context = function(ctx) {      let func = ctx.next().value; // function keyword      let func_name = ctx.next().value;      let args = ctx.next().value; // args      let body = ctx.next().value; // function body       let dummy = #`dummy`.get(0);      let context_id = #`${dummy.fromidentifier("$context$")}`;       let body_result = #`let ${context_id} = 1234`;      (let stx of body.inner()) {          body_result = body_result.concat(#`${stx}`);      }       return #`${func} ${func_name}${args}{${body_result}}`; }  context function foo(a, b) {     cdo bar(); } 

what want "context" macro call able assign local variable accessible/assignable inner cdo macro call.

this using sweet js 1.0, i've looked using name() access calling context, can't seem work. what's right way this?


Comments