2

I try to get the AST of a simple code-snippet in Nemerle, using Nemerle's quasi-quotes.

This is the code I tried:

def ast() : void {
  System.Console.WriteLine(<["Test"]>)
}

I ran it on IdeOne (ncc 0.9.3) and I got this error:

prog.nem:2:30:2:36: error: unbound name `Literal.String'
prog.nem:2:30:2:36: error: unbound name `PExpr.Literal'

How can I solve these issues?

3

You just need to add Nemerle.Compiler.dll as a reference to your project. Also, some of the more complex quasi-quotes will only work in macros.

using Nemerle.Compiler;
using System.Console;

macro Test()
{
    def x = <[ while (true) WriteLine(4) ]>.ToString();
    <[ WriteLine($x) ]>
}
| improve this answer | |
2

Quasi-quotations are intended for use in macros. They need a context of a compiler. Create a macro library project, and use a quasi-quotations in it.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.