Pregunta

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?

¿Fue útil?

Solución

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) ]>
}

Otros consejos

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top