Install
Quick Start (macOS Apple Silicon)
# Download and extract
curl -L https://github.com/Nerd-Lang/nerd-lang-core/releases/latest/download/nerd-darwin-arm64.tar.gz | tar -xz
cd nerd-darwin-arm64
# Write a program
echo 'out "Hello from NERD"
out five plus three' > hello.nerd
# Run it
./nerd run hello.nerd
# Output:
# Hello from NERD
# 8
# Optional: Add to PATH for global access
sudo mv ../nerd-darwin-arm64 /usr/local/nerd
echo 'export PATH="$PATH:/usr/local/nerd"' >> ~/.zshrc
# mul = 15
From Source
git clone https://github.com/Nerd-Lang/nerd-lang-core.git
cd nerd-lang-core/bootstrap
make
sudo make install
Prerequisites
NERD compiles to LLVM IR. You need clang to build native binaries.
macOS
xcode-select --install
# or
brew install llvm
Linux
# Ubuntu/Debian
sudo apt install build-essential clang
# Fedora
sudo dnf install clang gcc make
# Arch
sudo pacman -S clang gcc make
Windows
winget install LLVM.LLVM
Usage
# Compile to LLVM IR
nerd compile program.nerd -o program.ll
# Build native binary
clang -O2 program.ll -o program
Example
fn add a b
ret a plus b
fn mul a b
ret a times b
cd bootstrap
./nerd compile ../examples/math.nerd -o math.ll
cat math.ll test_math.ll > combined.ll
clang -O2 combined.ll -o math
./math
Commands
nerd compile <file> -o <out> | Compile to LLVM IR |
nerd run <file> | Compile and run |
nerd parse <file> | Show AST |
nerd tokens <file> | Show tokens |
nerd --version | Version |