Skip to content

JacoMalan1/wngc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WNG Compiler

Description

WNG is a toy language I am creating to develop my skills as a compiler developer. The acronym "WNG" stands for "WNG's Not Go". WNG is a statically-typed, compiled language powered by LLVM.

Grammar

A formal specification of the language's grammar can be found in the grammar.lalrpop file. The grammar is LR(1) parseable and the parser is generated using the LALRPOP parser generator for Rust.

Usage

Below is a short example program written in WNG that calculates and prints the first 10 fibonacci numbers.

fn fib(n: Number) -> Number {
  if n == 0 {
    return 0;
  }

  if n == 1 {
    return 1;
  }

  fib(n - 1) + fib(n - 2)
}

fn main() {
  for (i = 0; i < 10; i = i + 1;) {
    print fib(i);
  }
}

About

The WNG compiler

Resources

License

Stars

Watchers

Forks

Languages