Skip to content

Latest commit

 

History

21 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-lox

a personal go implementation of the lox interpreter from crafting interpreters by robert nystrom.

Tree-Walk Interpreter System Design
current progress on what I've learnt so far

built for learning, not for production.

current read: chapter 11

a peak interest in practicing go whilst revisiting the concepts of compilers and interpreters

what works so far

  • scanning - tokenizes lox source into tokens (strings, numbers, keywords, operators)
  • parsing - recursive descent parser that builds an AST from tokens
  • evaluating - tree-walk interpreter that executes the AST
  • variables - var declarations, assignment, block scoping with { }
  • control flow - if/else, while, for loops, logical and/or
  • functions - first-class functions, closures, recursion, return
  • static analysis - resolver pass for correct scope binding + compile-time error detection
  • native functions - clock() bridging go to lox
  • extras - % modulo operator, comma expressions

try it

# run a file
go run main.go test/phase4.lox

# or the repl
go run main.go

what's next

  • classes and inheritance (chapters 12-13)
  • test suite
  • language extensions (arrays, lambdas, string methods)
  • stdlib (file i/o, http, json)

About

Go implementation of an Interpreter from the Crafting Interpreters Book by Robert Nystrom

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages