Skip to content

agustingianni/gooselang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gooselang

Goose complete programming language

Compiler Phases

  • Lexing
    • Generates a token list
  • Parsing
    • Generates an AST
  • Import Resolution
    • Imports all the types from modules
  • Type Checking
    • Iteratively typechecks the AST
    • Constraint resolution
    • Type Inference
    • Generates a Typed AST
  • Code Generation
    • Lowering
    • Optimization
  • IL emit
    • Emit IL
    • Binary creation

Bindings

let name = 1

Modules

let MyModule = module {
    let x = 1
}

Types

let myStruct = struct {
    name : type
    name : type
}

let myUnion = union {
    name : type
    name : type
}

Functions

let inc = lambda (a) {
    a + 1
}

let sum = lambda (a, b) {
    a + b
}

let inc = lambda (a:int):int {
    a + 1
}

let sum = lambda (a:int, b:int):int {
    a + b
}

Array

let array = array { 1 ; 2 ; 3 }

let array = array {
    1
    2
    3
}

Tuple

let tuple = tuple { 1 ; "a" ; ident }

let tuple = tuple {
    1
    "a"
    ident
}

Dictionary

let dictionary = dict { 1 : "one" ; 2 : "two" }

let dictionary = dict {
    1 : "one"
    2 : "two"
}

Predicates

empty ? list

Symbols

s"HOLA"

Iteration

for x in things {
    printf x
}
repeat 1000
    printf "Hola!"

In / Out

open IO

printf "hola Agustin!"
let variable = "Agustin"
printf f"hola {variable}!"

Standard Library

String

The string type represents immutable text as a sequence of Unicode characters.

Methods

  • concat
  • join
  • indexOf
  • contains
  • startsWith
  • endsWith
  • remove
  • replace
  • split
  • substring
  • trim
  • trimStart
  • trimEnd
  • equals
  • toLower
  • toUpper
  • padLeft
  • padRight
  • length
  • find

Indexing

let s = "012345678"
s[0] == "0"
s[0 .. 2] = "012"
s[0 .. 2 .. 8] = "02468"

Array

List

Methods

  • fold
  • map

Set

Others

LINQ like DSL for provided types like arrays, sets etc.

Releases

No releases published

Packages

No packages published

Languages