The expression you enter is a constant, a literal string. So, you need to disassemble $iyourself. Here's an example using a regex and for bonus points to get its type in a calling context.
http://try-haxe.mrcdk.com/#B0B9E ( Build+run , )
import haxe.macro.Expr;
import haxe.macro.Context;
class Test {
static function main() {
var i = 1;
trace(m('some before $i some after'));
}
static macro function m(e: Expr)
{
trace(e);
var interpolated:String = null;
switch e.expr {
case EConst(CString(str)):
trace(str);
var r = ~/\$\w+/;
if (r.match(str)) {
interpolated = r.matched(0).substr(1);
trace(interpolated);
}
default: throw 'Macro m expects a string literal...';
}
if (interpolated!=null) {
var t = Context.typeof({expr: EConst(CIdent(interpolated)), pos:Context.currentPos()});
trace('Got interpolated var $interpolated of type $t');
}
return macro $e;
}
}