General
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.
Playground
Lox is the language Bob Nystrom builds in Crafting Interpreters, a book about writing lexers, parsers and interpreters. I worked through it and wrote my own interpreter for Lox in Java. Everything you run below is sent to that interpreter.
Press Run to send this program to the interpreter.
Everything Lox can do, with a snippet for each. Copy any of it into the editor above.
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.