Lox is a programming language by Bob Nystrom written for the book Crafting Interpreters. It is an excellent book that teaches how to build lexers, parsers and interpreters. After reading the book and having implemented the interpreter for Lox in Java, I decided to make a playground for it which runs the code on the Java Interpreter for Lox hosted on a server.
Lox's syntax is a member of the C family. It is a dynamically typed language. Braces { } denotes a block of code and // is used for comments.
Lox supports booleans, numbers, strings and nil. Variables can be declared with the 'var' keyword.
Lox supports the following basic arithmetic operators.
Lox supports if-else-if ladders.
Lox supports for loops and while loops.
You can create functions with the 'fun' keyword.
You can create classes with the 'class' keyword and initilaize them with the 'innit' method. 'this' keyword is used to refer to the current object
Lox supports single inheritance. When you declare a class, you can specify a class that it inherits from using '<' operator.