Expression parsing

This commit is contained in:
2026-04-14 02:28:15 +02:00
parent 511895d0f8
commit 5b01171ee4
2 changed files with 34 additions and 1 deletions
+5 -1
View File
@@ -14,12 +14,14 @@ inner_str = @{ (!"\"" ~ ANY)* }
// ================= TOP LEVEL =================
export = { "export"? }
import_decl = { "import" ~ string_lit ~ ";" }
param_list = { param ~ ("," ~ param)* ~ ","? }
param = { identifier ~ ":" ~ type_expr }
function_decl = {
"function" ~ identifier ~ "(" ~ param_list? ~ ")" ~ (":" ~ type_expr)? ~ block
export ~ "function" ~ identifier ~ "(" ~ param_list? ~ ")" ~ (":" ~ type_expr)? ~ block
}
// ================= STATEMENTS =================
@@ -30,3 +32,5 @@ statement = _{ "idk" }
// ================= EXPRESSIONS =================
type_expr = _{ identifier }
expr = { identifier | integer | float | boolean | string_lit }