tags:

views:

49

answers:

1

Hi,

I am creating nested macros in BOO, I wrote this program:

macro text:
  macro subMacro:
    text["Text"] = "Hello World"

  return [|
    block:  
      System.Console.WriteLine( "Hello World" );
  |]

But I am getting the error "Unknown Identifer: 'text'" in the 3rd line of the code.

+1  A: 

The error you are getting is likely to do with a missing import in the code where the macro is being called from.

If your macro is in a namespace named foo for example, you will need to add

import foo

At the top of the calling code.

A second issue you may run into once you fix this compiler issue is the error

"Unknown identifier 'block' (BCE0005)

To fix this, add a .Body after the quasi-quotation section like this:

import Boo.Lang.Compiler.Ast

macro text:
    macro subMacro:
        text["Text"] = "Hello world"

    return [|
        block:
            System.Console.WriteLine("Hello World");
    |].Body

EDIT - IMHO macros are a bit of a dark art. For more help, you should try the boo mailing list, or the excellent DSLs in BOO

matt