Macros - The Nitrate Programming Language

Informal Overview

Nitrate preprocessor macro tokens cannot be specified with EBNF because they rely on a context-sensitive grammar.

Examples of Macros

// Transform the argument into an uppercase string literal
// Example: "John Doe" -> "JOHN_DOE"
@(fn MY_MACRO(name) {
  return quix.enstr(name:gsub(" ", "_"):upper())
})

// The argument is interpreted as LUA code
@MY_MACRO("John Doe")
// This is also valid (and equivalent to the first example)
@(function MY_MACRO(name)
  return quix.enstr(name:gsub(" ", "_"):upper())
end)

@(return MY_MACRO("John Doe"))
// Call a simple LUA builtin function
@print("Hello from the preprocessor")

Macro Standards

Macros are very complicated to describe in a formal grammar. See the source code for more information.