Lexemes

Identifiers

digit        ::= "0"  "9"
lower_letter ::= "a"  "z"
upper_letter ::= "A"  "Z"
letter       ::= lower_letter
               | upper_letter
alphanumeric ::= digit
               | letter
lower_ident  ::= lower_letter ( alphanumeric )*
upper_ident  ::= upper_letter ( alphanumeric )*

The language distinguishes between identifiers that start with an upper-case letter and identifiers that start with a lower-case letter. Upper-case identifiers are used for the names of types and modules. Lower-case identifiers are used for the names of functions and variables.

Reserved identifiers

The following are reserved as keywords and builtin constants by the language. Use of these keywords and constants as identifiers will cause a syntax error.

else    false   fn
if      let     match
mod     native  true
type    use

Literals

There are literal forms for strings, floating-point numbers, integer numbers, and boolean constants.

literal ::= string_literal
          | float_literal
          | integer_literal
          | boolean_literal

String literals

string_literal ::= `"` ( inline_whitespace | alphanumeric )* `"`

String literals are wrapped in double quotes and cannot contain newline characters. All string literals are of the type Str.

Floating-point literals

float_literal ::= ( digit )+ "." ( digit )+

Floating point literals must have 1 or more digits before the decimal point and 1 or more digits after the decimal point. All floating point literals are of the type Float.

Integer literals

integer_literal ::= ( digit )+

Integer literals have 1 or more digits. There is currently no support for numeric separators or scientific notation. All integer literals are of the type Int.

Boolean literals

boolean_literal ::= "true"
                  | "false"

Boolean literals are expressed as either the true constant or the false constant. All boolean literals are of the type Bool.

Comments

Comments start with -- and continue until the end of the line.