Skip to content
Public template

About

nova-lang

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation

Nova

A statically typed programming language and compiler built with Python and LLVM.

Nova is designed to provide a simple programming experience while compiling programs to native code through LLVM.


Overview

Nova is a compiled programming language with its own language syntax, compiler frontend, type system, and LLVM-based backend.

The project explores how a programming language works internally — from source code and lexical analysis to parsing, semantic analysis, type checking, and LLVM-based code generation.

Compiler Pipeline

Source Code
     │
     ▼
   Lexer
     │
     ▼
   Parser
     │
     ▼
    AST
     │
     ▼
Semantic Analysis
     │
     ▼
 Type Checking
     │
     ▼
 LLVM IR
     │
     ▼
 Native Code

Why Nova?

Nova was built to explore compiler design and understand how high-level programming languages are translated into executable code.

The language combines:

  • Simple syntax
  • Static typing
  • Structured programming
  • Top-level scripting
  • LLVM-based compilation
  • Native code generation

Language Features

Nova currently includes language features such as:

  • Variables
  • Static types
  • Functions
  • Structs
  • Arrays
  • Control flow
  • Top-level scripting
  • Input and output
  • Type checking
  • LLVM-based code generation

Example

A simple Nova program:

struct Point {
    int x
    int y
}

print("Hello, Nova!")

string name = input("Enter name: ")

func greet(string n) -> int {
    print("Welcome,", n)
    return 0
}

greet(name)

Nova supports both simple top-level scripts and structured programs using functions and types.


Compiler Architecture

1. Lexer

The lexer converts source code into a sequence of tokens that can be processed by the compiler.

Source Code
     ↓
   Tokens

2. Parser

The parser consumes the tokens and constructs the program's abstract syntax tree.

Tokens
   ↓
 Parser
   ↓
  AST

3. Abstract Syntax Tree

The AST represents the structure and meaning of the source program in a form that later compiler stages can process.


4. Semantic Analysis

Semantic analysis validates the program beyond syntax.

This stage handles language-level checks required before code generation.


5. Type Checking

Nova uses static typing to detect type-related errors during compilation rather than waiting until runtime.


6. LLVM IR Generation

The compiler generates LLVM Intermediate Representation (LLVM IR) as the backend representation.

Nova Source
     ↓
 Compiler Frontend
     ↓
   LLVM IR
     ↓
 LLVM Backend
     ↓
 Native Code

LLVM provides the infrastructure required to transform the generated IR into native executable code.


Getting Started

Option 1 — Run the packaged version

Download the latest release and extract the archive.

Then run:

nova hello.nv

Option 2 — Build From Source

Nova can be packaged into an executable using PyInstaller.

Windows

pyinstaller --onefile --name nova --add-data "runtime;runtime" --add-data "compiler;compiler" cli/nova.py

Linux / macOS

./build.sh

Example Workflow

Create a Nova source file:

hello.nv

Add:

print("Hello, Nova!")

Then run:

nova hello.nv

The compiler processes the source program and uses LLVM as the compilation backend.


Technologies

  • Python — compiler implementation
  • LLVM — intermediate representation and compilation backend
  • LLVM IR — intermediate representation
  • PyInstaller — executable packaging

What I Learned

Building Nova provided hands-on experience with:

  • Compiler architecture
  • Lexical analysis
  • Parsing
  • Abstract syntax trees
  • Semantic analysis
  • Static type checking
  • Intermediate representations
  • LLVM IR
  • Code generation
  • Language design
  • Building developer tools from scratch

Current Status

Nova is an ongoing compiler project.

The current implementation supports core language constructs, static typing and LLVM-based compilation. The language and compiler architecture are still evolving as new features and improvements are explored.


Roadmap

Potential areas for future development include:

  • Expanding the type system
  • Improving compiler diagnostics
  • Additional language constructs
  • More optimisation work
  • Standard library development
  • Improved tooling
  • Better compiler error messages

About

nova-lang

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages