|
|
|
@ -5,11 +5,14 @@ block_line = _{ expr | (statement ~ MLF)* }
|
|
|
|
|
statement = { (decl | type_decl | expr) ~ TERMINATE }
|
|
|
|
|
decl = { "let" ~ #name = ident ~ #args = (ident)* ~ "=" ~ expr }
|
|
|
|
|
|
|
|
|
|
type_decl = { "type" ~ #name = type_ident ~ "=" ~ type_expr }
|
|
|
|
|
type_expr = { tuple | type_ident }
|
|
|
|
|
tuple = { "#(" ~ type_expr* ~ ")" }
|
|
|
|
|
type_ident = ${ #name = ident ~ #args = type_args? }
|
|
|
|
|
type_args = { "<" ~ type_ident* ~ ">" }
|
|
|
|
|
type_decl = { "type" ~ #name = type_ident ~ "=" ~ type_expr }
|
|
|
|
|
type_expr = { tuple | rec | type_ident }
|
|
|
|
|
tuple = { "#(" ~ MLF ~ tuple_entry* ~ MLF ~ ")" }
|
|
|
|
|
tuple_entry = _{ type_expr ~ MLF }
|
|
|
|
|
rec = { "#{" ~ MLF ~ (rec_field ~ TERMINATE ~ MLF)* ~ rec_field? ~ MLF ~ "}" }
|
|
|
|
|
rec_field = { #field_name = ident ~ ":" ~ #field_type = type_expr* }
|
|
|
|
|
type_ident = ${ #name = ident ~ #args = type_args? }
|
|
|
|
|
type_args = { "<" ~ MLF ~ type_ident* ~ MLF ~ ">" }
|
|
|
|
|
|
|
|
|
|
expr = { infix_expr | call_expr | term }
|
|
|
|
|
term = _{ ident | literal | "(" ~ MLF ~ expr ~ MLF ~ ")" | block }
|
|
|
|
|