var MP = new MacroProcessor(prelude, sink); MP.AddMacros(typeof(LeMP.Prelude.Macros).Assembly); MP.PreOpenedNamespaces.Add(GSymbol.Get("LeMP.Prelude"));
In order for the input code to have access to macros, two steps are necessary: you have to add the macro classes with AddMacros and then you have to import the namespace that contains the class(es). Higher-level code (e.g. Compiler) can define "always-open" namespaces by adding entries to PreOpenedNamespaces, and the code being processed can open additional namespaces with a #importMacros(Namespace) statement (in LES, "import macros Namespace" can be used as a synonym if PreOpenedNamespaces contains LeMP.Prelude). #import
, or by import
which is defined in the LES prelude); to scan the input for macros to call; and to control the printout of messages.