Could Nemerle support embedded TypeScript?

69 views
Skip to first unread message

Bruce Anderson

unread,
Feb 9, 2013, 7:53:40 AM2/9/13
to nemer...@googlegroups.com
I'm new to Nemerle, trying to skip to the advanced stuff without mastering the basics, never a good thing.

Can anyone suggest if it is possible to create a macro in Nemerle which would interpret:

var s = "hello";

as

mutable s = "hello";

If so, how?

In general I'm wondering if Nemerle's macros would be powerful enough to be able to interpret embedded TypeScript without much manipulation, with the help of macros? This was my first test, and already I'm stuck.

Bruce

NN

unread,
Feb 9, 2013, 9:58:47 AM2/9/13
to nemer...@googlegroups.com
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-parser

There 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 :)

NN

unread,
Mar 6, 2013, 4:38:53 AM3/6/13
to nemer...@googlegroups.com
Hey,

The parser has been updated according to the specification : https://github.com/NemerleWeb/NemerleWeb/blob/master/NemerleWeb/TSDeclarationParser.n
You are free to add full code parsing :)
Reply all
Reply to author
Forward
0 new messages