Skip to content

Hamdan-Khan/interpreter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Interpreter

A tree-walk interpreter for lox programming language written in Go.

It uses the grammar defined in crafting interpreters book by Rob Nystrom. You can find the grammar here.

Currently, it doesn't support classes but I plan to add them in the future. This is more of a learning project for me than an attempt to create a perfectly working interpreter. I have documented the learning and the process of working of a tree-walk interpreter in this blog.

Syntax

Functions

fun sum(a, b) {
    return a + b;
}

Print

print "Hello world";

Variables

var a = 1;

If

if (true) {
    print "true";
} else {
    print "false";
}

While

while (condition) {
    print "loop";
}

For

for (var i = 0; i < 10; i = i + 1) {
    print i;
}

Usage

go run . test.txt

About

A tree-walk interpreter written in Go

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages