Git Product home page Git Product logo

ktlox's Introduction

KtLox

Kotlin Treewalk Interpreter for Lox

Introduction

KtLox is an implementation of the programming language Lox in Kotlin. Currently it uses naive treewalk interpreter, and is not optimized for speed. The initial version of KtLox has only features already present in the original JLox/CLox, but subsequent versions will continue to add new features to make it a powerful language. This is an experiment on the design and implementation of language features.

The original version of Lox programming language can be found at Bob Nystrom's repository: https://github.com/munificent/craftinginterpreters

Features

  • Lexer, Parser and Treewalk Interpreter
  • Unary and Binary Expression/Operators
  • If and Else Statement
  • While and For Loop
  • Break Statement(challenge from the book)
  • Scope and Environment
  • Functions and Closures
  • Resolver and Semantic Analysis
  • Anonymous Functions(challenge from the book)
  • Classes and Objects
  • Methods and Property Getters
  • Inheritance and this/super keywords
  • Metaclasses(challenge from the book)
  • Traits(challenge from the book)
  • Object root class for every class in Lox(since v1.1.0)
  • Framework for creating native functions/classes(since v1.1.0)
  • Standard Library for KtLox(since v1.2.0)
  • Require/Include other Lox script/library files(since v1.2.0)

Roadmap

KtLox v1.1.0

  • Improved object model - Everything is an object, including nil, true, false, number, string, etc.
  • Framework for writing Native functions and classes.
  • Root class Object which serves as superclass of every class.
  • Remove print statement and replace it by print/println native functions.

KtLox v1.2.0(current version)

  • Full Fledged Standard Library: Boolean, Number, String, Array, Dictionary, DateTime, etc.
  • Move all native classes from common package to the std.lang package.
  • Allow customized runtime configurations for KtLox at startup with config.properties
  • Split the Number class, which will distinguish between integers and floating numbers.

KtLox v1.3.0(next version)

  • Array/Dictionary Literals and square bracket notation for array/dictionary access.
  • Short closures/lambda expression with nonlocal returns.
  • Replace C style for loop by Kotlin style for-in loop for collection.
  • Improved Collection framework/library for KtLox
  • (maybe) Null-safe operator (?.).

KtLox v1.4.0

  • Immutable variable declaration with val.
  • Function/method parameters are immutable by default(unless var keyword is used).
  • Classes, functions and traits are immutable variables.
  • (maybe) Allow properties/instance variables to be defined inside the class statements, instead of initializers.

KtLox v1.5.0

  • Refinement of metaclass system to match smalltalk's metaobject protocol.
  • Improvement of trait system in KtLox.
  • Add some Metaclasses and traits to the standard library.
  • (maybe) Add feature for anonymous class and trait.

KtLox v1.6.0

  • Introduction of Namespace for KtLox's module system.
  • Allow importing namespaces and aliasing of imported classes/functions.
  • Redesign the existing standard library with namespaces(KtLox.Standard package).

KtLox v1.7.0

  • Exception handling: throw statement, try/catch/finally statement, etc.
  • Add class Exception as well as a few more exception subclasses to the standard library.
  • (maybe) Pattern Matching

KtLox v1.8.0

  • Operator Overloading: enable user defined classes to overload operators, these operators are treated as method calls.
  • Method interception when an undefined method call is invoked on an object/class, similar to Smalltalk's doesNotUnderstand: message.
  • (maybe) Semicolon inference that allows semicolons to be omitted when its obvious that the statement is finished at the end of the line.

KtLox v1.9.0

  • Introduction of async and await keywords, which allows C#/JS style of concurrency.
  • Add class Promise(or Future) to the standard library, which represents an async task to be completed in future.
  • (maybe) Continuation and Context, similar to smalltalk style stack manipulation.

KtLox v2.0.0

  • Optional static typing support for instance variables and function/method parameters.
  • (maybe) Type inference for immutable variables, as well as possible optimization for typed variables.
  • (maybe) Slot as reified variables, similar to Pharo Smalltalk and Self's implementation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.