update parser

This commit is contained in:
2024-02-19 02:54:02 +07:00
parent 546af734e7
commit 6a27f8fdf8
4 changed files with 516 additions and 61 deletions

View File

@ -1,9 +1,44 @@
; declare a module
module main
c : fn => bool = function is
let a = b in
c(a)
; no explicit export so everything in this module is exported
export one, two
b : bool = false
; no import
import a
import a only name, name
import a as change_name
a : number = 1
; declare a variable
one : number = 1
; declare a variable that is computed
; places a burden on the runtime
two : number = one + 1
; tt : bool = true
; types can be named, alias
; using tuple or record or enum
type coordinates_tuple = tuple (number, number)
; type coordinates_record = record { x : number , y : number }
coordinates_as_tuple : coordinates_tuple = tuple (1, 2)
; coordinates_as_record : coordinates_record = record { x : 1 , y : 2 }
; function definition is structured the same
void : fn => number = function is
let x = 1 in
1
return_false : fn => bool = function is
false
increment : fn number => number = function x is
x + 1
is_even : fn number => bool = function x is
if x % 2 then true else false
bruh : number = increment(one)