|
|
@ -1,9 +1,11 @@
|
|
|
|
file = { "hello world" }
|
|
|
|
file = {
|
|
|
|
|
|
|
|
SOI ~ MLF ~ (statement ~ MLF)* ~ EOI
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
block = { "{" ~ MLF ~ block_line ~ MLF ~ "}" }
|
|
|
|
|
|
|
|
block_line = _{ expr | (statement ~ MLF)* }
|
|
|
|
|
|
|
|
statement = { (decl | type_decl | expr) ~ TERMINATE }
|
|
|
|
statement = { (decl | type_decl | expr) ~ TERMINATE }
|
|
|
|
decl = { "let" ~ #name = ident ~ #args = (ident)* ~ "=" ~ expr }
|
|
|
|
decl = { "let" ~ #name = ident ~ #args = (ident)* ~ "=" ~ expr }
|
|
|
|
|
|
|
|
block = { "{" ~ MLF ~ block_line ~ MLF ~ "}" }
|
|
|
|
|
|
|
|
block_line = _{ expr | (statement ~ MLF)* }
|
|
|
|
|
|
|
|
|
|
|
|
type_decl = { "type" ~ #name = type_ident ~ "=" ~ type_expr }
|
|
|
|
type_decl = { "type" ~ #name = type_ident ~ "=" ~ type_expr }
|
|
|
|
type_expr = { tuple | rec | enum | type_ident }
|
|
|
|
type_expr = { tuple | rec | enum | type_ident }
|
|
|
@ -14,8 +16,8 @@ tuple_entry = _{ type_expr ~ MLF }
|
|
|
|
rec = { "#{" ~ MLF ~ (rec_field ~ TERMINATE ~ MLF)* ~ rec_field? ~ MLF ~ "}" }
|
|
|
|
rec = { "#{" ~ MLF ~ (rec_field ~ TERMINATE ~ MLF)* ~ rec_field? ~ MLF ~ "}" }
|
|
|
|
rec_field = { #field_name = ident ~ ":" ~ #field_type = type_expr* }
|
|
|
|
rec_field = { #field_name = ident ~ ":" ~ #field_type = type_expr* }
|
|
|
|
|
|
|
|
|
|
|
|
enum = { "#[" ~ (enum_vrt ~ TERMINATE ~ MLF)* ~ enum_vrt? ~ "]" }
|
|
|
|
enum = { "#[" ~ MLF ~ (enum_vrt ~ TERMINATE ~ MLF)* ~ enum_vrt? ~ "]" }
|
|
|
|
enum_vrt = { #vrt_name = ident ~ type_expr }
|
|
|
|
enum_vrt = { #vrt_name = ident ~ type_expr? }
|
|
|
|
|
|
|
|
|
|
|
|
type_ident = ${ #name = ident ~ #args = type_args? }
|
|
|
|
type_ident = ${ #name = ident ~ #args = type_args? }
|
|
|
|
type_args = { "<" ~ MLF ~ type_ident* ~ MLF ~ ">" }
|
|
|
|
type_args = { "<" ~ MLF ~ type_ident* ~ MLF ~ ">" }
|
|
|
@ -46,8 +48,10 @@ float = @{
|
|
|
|
byte = @{ "0x" ~ ASCII_HEX_DIGIT{1, 2} | "0b" ~ ASCII_BIN_DIGIT{0, 8} }
|
|
|
|
byte = @{ "0x" ~ ASCII_HEX_DIGIT{1, 2} | "0b" ~ ASCII_BIN_DIGIT{0, 8} }
|
|
|
|
boolean = @{ "true" | "false" }
|
|
|
|
boolean = @{ "true" | "false" }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
KEYWORD = _{ "let" }
|
|
|
|
|
|
|
|
TERMINATE = _{ LF | EOI | ";" }
|
|
|
|
|
|
|
|
MLF = _{ (LF)* }
|
|
|
|
|
|
|
|
LF = _{ "\n" | "\r" }
|
|
|
|
|
|
|
|
|
|
|
|
WHITESPACE = _{ " " | "\t" }
|
|
|
|
WHITESPACE = _{ " " | "\t" }
|
|
|
|
KEYWORD = _{ "let" }
|
|
|
|
COMMENT = _{ "/*" ~ (!"*/" ~ ANY)* ~ "*/" }
|
|
|
|
TERMINATE = _{ LF | EOI | ";" }
|
|
|
|
|
|
|
|
MLF = _{ (LF)* }
|
|
|
|
|
|
|
|
LF = _{ "\n" | "\r" }
|
|
|
|
|
|
|
|