Skip to content
This repository has been archived by the owner on Apr 30, 2019. It is now read-only.
/ golox Public archive

A go implementation of Lox language.

Notifications You must be signed in to change notification settings

aliwalker/golox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Golox

This repo is a go implementation of Lox language. Lox is a dynamic scripting language designed by Bob Nystrom in his book Crafting Interpreter. Lox is really like JavaScript. Refer to chapter 3 of the book for an overview of Lox lang.

This implementation adds some more features:

  • Semicolon is not a must. :-)
  • Lambda expressions(anonymous functions).
  • Support break statement from loops.
  • Support getters/setters, static methods for classes.
  • Support for ... of statement.
  • Support Arrays, Maps.
  • Enhanced REPL.

Example

fun fibnacii() {
    var prev = 0, cur = 0

    // lambda expression.
    return () -> {
        if (cur == 0) {
            cur = 1
            return 0
        }

        var res = cur
        cur += prev
        prev = res

        return res
    }
}

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

About

A go implementation of Lox language.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published