Var decl kind

This commit is contained in:
2026-04-14 05:57:32 +02:00
parent b2fa1e24e1
commit b4faebd34e
2 changed files with 4 additions and 4 deletions
+4 -2
View File
@@ -60,8 +60,10 @@ continue_stmt = { "continue" ~ ";" }
// --- variable declarations --- // --- variable declarations ---
var_decl_kind = { "let" | "const" | "var" }
var_decl = { var_decl = {
("let" | "const" | "var") ~ identifier ~ ("=" ~ expr)? ~ ";" var_decl_kind ~ identifier ~ ("=" ~ expr)? ~ ";"
} }
// --- control flow --- // --- control flow ---
@@ -80,7 +82,7 @@ for_stmt = {
// helper (same as var_decl but no trailing ;) // helper (same as var_decl but no trailing ;)
var_decl_no_semicolon = { var_decl_no_semicolon = {
("let" | "const" | "var") ~ identifier ~ ("=" ~ expr)? var_decl_kind ~ identifier ~ ("=" ~ expr)?
} }
// ================= EXPRESSIONS ================= // ================= EXPRESSIONS =================
-2
View File
@@ -1,13 +1,11 @@
function add(a: int, b: int): int { function add(a: int, b: int): int {
let sum = 0; let sum = 0;
for (let i = 0; i < 10; i = i + 1) {
if (i == 5) { if (i == 5) {
continue; continue;
} }
sum = sum + i; sum = sum + i;
}
if (sum > 20) { if (sum > 20) {
return sum; return sum;