Hey
macro var is relative simple:
using Nemerle.Compiler;
macro @var (body)
syntax ("var", body)
{
match (body) {
| <[ $(nm : name) ]> => <[ mutable $(nm : name); ]>
| <[ $(id : name) = $init ]> => <[ mutable $(id : name) = $init; ]>
| <[ $name = $init ]> => <[ mutable $name = $init; ]>
| _ => Message.FatalError ($"incorrect variable definition '$body'");
}
}
But you cannot implement whole TypeScript using macros.
You can however implement front-end for Nemerle compiler for TypeScript language, like we have for C#:
https://github.com/rsdn/nemerle/tree/master/snippets/csharp-parserThere is project
NemerleWeb where we have
TypeScript declarations parser (*.d.ts files).
The parser is not fully complete but this work is in progress, so it will be drastically changed.
Although it won't parse TypeScript implementation files, only declarations, but you can use it for implementing the full TypeScript parser and add language that Nemerle compiler can compile :)