Skip to content

xirzo/MyLang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

108 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is a simple interpreter written in Zig in order to learn it. It utilizes Pratt parsing technique.

Build

Clone the repository

git https://github.com/xirzo/mylang && cd mylang

Build the interpreter

zig build

Get into bin directory

cd ./zig-out/bin

Run the executable

./mylang sample.my

sample.my

fn fib(n) {
    if n <= 1 {
        ret n;
    }

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

println(fib(5));

Features

  • structs (as objects)
  • if statements
  • built-in functions (e.g. println)
  • function declarations
  • function calls
  • blocks
  • let statements
  • return statements
  • infix operators
  • prefix operators
  • postfix operators
  • reassignments
  • for loops
  • while loops
  • [] else statements

Sources

About

A toy language interpreter written in Zig

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages