-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Defining macros results in compiler errors #13343
Comments
How you do you compile? You have to compile with reference of Nemerle.Macro.dll. |
I created a Nemerle project and added a macro using macro wizard. However the generated code contains too much redundancy ("generated code contains code that obviously doesn't appear in the example" + "the example macro in the tutorial can work" => "most of the code is unneeded for a simple macro test") so I deleted those. Here's what I got using macro wizard (expression level, does not define a syntax extension): using Nemerle;
using Nemerle.Collections;
using Nemerle.Compiler;
using Nemerle.Compiler.Parsetree;
using Nemerle.Compiler.Typedtree;
using Nemerle.Text;
using Nemerle.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
namespace NemerleExercises.Macros.Tutorial
{
macro Macro1()
{
Macro1Impl.DoTransform(Macros.ImplicitCTX(), )
}
module Macro1Impl
{
public DoTransform(typer : Typer, ) : PExpr
{
Macros.DefineCTX(typer);
// TODO: Add implementation here.
;
}
}
} The piece of code raises errors described above; also, you can see that formal parameter list of For compiling, I use the default method provided by Nemerle VS extension. That is, |
Well I got it. Since the tutorial didn't mention it, and Nemerle is known as a meta-programming language, I thought macros feature is included in the Nemerle runtime (i.e. Thank you for the tip. |
Sorry it still doesn't get fixed. ( The IntelliSense does not prompt anything in the macro definition now. (There used to be "unbound names" errors.) But when I try the macro "unbound name" appears at the usage. On the other hand, when compiling the project, the compiler still throws "unbound names" error. I'm sure that |
There is no intellisense inside macro. If you create using VS wizard, it does this automatically. |
Thanks for the reply. My point is not about IntelliSense, but a inconsistency between IntelliSense and the compiler, on the same piece of code. Reading the tutorial again, the assembly that has to be referenced is Code: using Nemerle.Compiler;
using Nemerle.Compiler.Parsetree;
using Nemerle.Compiler.Typedtree;
// Taken directly from the tutorial
macro m () {
Nemerle.IO.printf ("compile-time\n");
<[ Nemerle.IO.printf ("run-time\n") ]>;
}
VS Nemerle project, adding VS Nemerle project, adding However, under none of these case can I use the compiled macro. Consider the code: using Nemerle;
using Nemerle.Collections;
using Nemerle.Text;
using Nemerle.Utility;
using Nemerle.Compiler;
using Nemerle.Compiler.Parsetree;
using Nemerle.Compiler.Typedtree;
// Again, taken directly from the tutorial
macro m () {
Nemerle.IO.printf ("compile-time\n");
<[ Nemerle.IO.printf ("run-time\n") ]>;
}
namespace NemerleExercises.Macros.Tutorial {
module Program {
Main(): void {
// Here if you input "mMacro." and wait for the completion list you can see that the macro class exists,
// so the macro itself can be compiled.
// But this usage raises "unbound name 'm'" error.
m();
_ = System.Console.ReadKey();
}
}
}
|
If you didn't reference |
I'm following Macros tutorial. When I try to create a macro for the first exercise, IntelliSense throws an error:
error : unbound type name 'IMacro'
.Macro code:
The compiler throws more errors, all of them are unbound names:
GrammarElement
,PExpr
,SyntaxElement
, etc.I'm using Nemerle for Visual Studio version 1.2.547.0. I assume the compiler is of the same version.
This error also shows up on online environments, for example this one. They are using ncc 1.2.0.
The text was updated successfully, but these errors were encountered: