Syntax

Overall syntax

DESIGN NOTE:

In Lit v1.0, the syntax is not so easy on eyes as I'd like to. There's limitations in my current knowledge about compilers, so I'll make some compromisses. However, in v2.0, I'll (hopefully) be able to get rid of them.

Check v2.0 docs for the syntax I'm aiming for.

Comprimisses of v1.0:

  • All statements are ended with a ;;

  • All numbers are Float;

  • Variable declaration require the let keyword;

  • Function declaration require the fn keyword;

  • Variables are actually mutable;

Variables

In version 1.0, Lit will require the keyword let for declaring variables.

let a = 1;
# => 1

let b = 2;
# => 2

let c = a + b;
# => 3

# You can redefine variables
a = "other value";
# => "other value"

Using keywords as variables will cause an error:

Allowed variable names

Variable names must begin with a letter (A-Z or a-z) or underscore. After that any letter, number or ? and ! is allowed.

Numbers

Mathematical Operations and Elementary Functions

Strings

There's no difference between single-quoted and double-quoted strings. They both can be interpolated:

Functions

Control Flow

Types?

Data Structures (better name)

Modules

Last updated

Was this helpful?