Skip to content

Latest commit

 

History

History
60 lines (49 loc) · 1.92 KB

README.md

File metadata and controls

60 lines (49 loc) · 1.92 KB

Florence Programming Language

Toy language developed using Go's lexer/parser/ast/SSA/compiler as a basis

Basic program

:: Program main

fn main() {
    a := 1 + 2
    print(a) // 3
}

Types

Struct

type Foo struct {}

Attaching a method to a struct

By value
Foo :: fn Do(){}

Invoking the method

fn main() {
    foo := Foo{}
    foo.Do()
}
Using the it keyword
Foo :: fn Do() {
    print(it) // "it" refers to the copy of "Foo" passed into this method.
}
By pointer/ref
*Bar :: fn Do(){}
Using the it keyword with the @ dereference operator
type Bar struct {
    int fps
}

*Bar :: fn Do(){
    // Read as "the val at (@) 'it' (where 'it' is a pointer of type Bar)"
    @it.fps = 60

    ...

    it.fps = 60 // Compile error. A pointer of type Bar does not have a field named "fps"

}