Skip to content
Nikitin Ilya edited this page Mar 24, 2019 · 10 revisions

========== Incomplete! ==========

Variables

Example Description
let x = new Something(), let x: Int Immutable value declaration
let x = 42, let x = 'Hello!' Constant value decalration (case of primitive type assignment)
x = 42, x: Int, x: Int = 42 Variable declaration

Functions

Function definition (without body)
fn greet: No return value, no parameters
fn greet (name: Str): No return value
fn greet (name: Str, surname: Str): No return value, multiple parameters
fn get-response => Str: With return value, no parameters
fn response (input: Str) => Str: With return value and parameter
fn makemap<T>(g: T, seq: List<T>): Generic function
Lambda (anonymous) function
(arg1: Int, arg2: Int) => With multiple parameters
(1 to 5).map(x => x * x) With single named input argument x

'match' construction

Simple comparison:

digitAsWord = x match
    | 1 => "one"
    | 2 => "two"
    | 3 => "three"
    # ...
    | 9 => "nine"
    | _ => raise ArgumentOutOfRangeError

Pattern-matching:

alert = notification match
    | Email(email, title, _)     => f"Email from {email} with title: {title}"
    | SMS(number, message)       => f"SMS from {number}! Message: {message}"
    | VoiceRecording(name, link) => f"Voice Recording from {name}! Click to hear it: {link}"

Introduction to language syntax

Expressions

Toolset architecture

Public compiler interface

  • Units & Modules - TODO
  • Compiler class

Backend

  • Lexer (Tokenizer)
  • Syntax tree
  • Traversing

Miscellaneous

Clone this wiki locally