nfl/compiler

The compiler orchestration layer: ties the reader, macro expander, and lowering/backend passes together, and exposes the two Nim macros (nflExpr, nflModule) that the nfl CLI's generated wrapper calls to turn .nfl source into Nim AST at compile time.

Procs

proc expandSource(source, file: string; autoloadCore = true; importDir = ""): seq[
    Syntax] {....raises: [CompilerError, Exception, ReaderError, IOError,
                       ValueError, KeyError],
              tags: [RootEffect, ReadDirEffect, ReadIOEffect], forbids: [].}
Reads source (labelled file for diagnostics) and fully macro-expands it, optionally auto-loading std/core.nfl first. Returns the expanded top-level forms; does not lower or emit Nim code.

Macros

macro nflExpr(source: static[string]; autoloadCore: static[bool] = true): untyped
Expands, lowers, and emits a single NFL expression as a Nim expression, for embedding NFL snippets directly in Nim code.
macro nflModule(source: static[string]; file: static[string] = "<nflModule>";
                autoloadCore: static[bool] = true;
                emitNim: static[bool] = false; importDir: static[string] = ""): untyped
Expands, lowers, and emits an entire NFL source file as top-level Nim declarations. This is what the nfl CLI's generated wrapper calls to compile a .nfl file via nim c/check. When emitNim is set, the resulting NimNode's .repr is echoed (between marker lines) once emission succeeds -- this is what nfl's --emit nim flag turns on; it is a best-effort debug dump, not guaranteed to be re-compilable Nim. importDir overrides where a relative (import ./x.nfl) resolves from — see expandSource's own doc comment; every caller but nfl repl leaves it empty and gets the existing parentDir(file) behavior.