Skip to content

aurelilia/klox

Repository files navigation

KLox

An interpreter for Lox. Written in Kotlin.

Currently in progress of being rewritten for Graal/Truffle.

Notable differences to jLox

  • C-style multiline comments (/* ... */) implemented; can be nested
  • C-style ternary operator implemented
  • Strings can be concatenated with anything
  • Division by 0 causes a RuntimeError instead of NaN
  • Variables are not initialized to nil by default; access before initialization leads to a RuntimeError
  • Maximum function arguments are 16 instead of 8
  • 'print $obj' statement is replaced by print($obj) and printLine($obj) native functions
  • More native functions, see Interpreter class for a list of them

Build/Run

# Run as REPL
./gradlew run

# Execute $file
./gradlew run $file

Code style

Follow the style used by the default code formatter in IntelliJ IDEA. Max line length is 150.

About

A kotlin interpreter for the Lox language

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages