@ -43,6 +43,13 @@ add2 4
// nested function calls
add2 (sub4 (mul2 4))
// if is an expression that can return a value
let value =
if a == b then
a
else
b
```
### Declarations
@ -3,7 +3,7 @@ file = {
}
statement = { (decl | type_decl | expr) ~ TERMINATE }
decl = { "let" ~ #name = ident ~ #args = (ident)* ~ #type = type_annot? ~ "=" ~ expr }
decl = { "let" ~ #name = ident ~ #args = (ident)* ~ #type = type_annot? ~ "=" ~ MLF ~ expr }
block = { "{" ~ MLF ~ block_line ~ MLF ~ "}" }
block_line = _{ expr | (statement ~ MLF)* }
@ -12,6 +12,12 @@ if 1 != 1 then {
a + 1
======
(file
@ -88,5 +94,27 @@ if 1 != 1 then {
)
(statement
(decl
(ident: "value")
(expr
(if
(infix_expr
(ident: "a")
(operator: "==")
(ident: "b")
(EOI: "")