Opertators

This commit is contained in:
2026-04-14 04:47:53 +02:00
parent 3223a8c854
commit 5a52582977
2 changed files with 14 additions and 23 deletions
+13 -13
View File
@@ -37,15 +37,15 @@ block = { "{" ~ statement_list ~ "}" }
statement_list = { statement* } statement_list = { statement* }
statement = _{ statement = _{
expr_stmt expr_stmt
| var_decl | var_decl
| if_stmt | if_stmt
| while_stmt | while_stmt
| for_stmt | for_stmt
| return_stmt | return_stmt
| break_stmt | break_stmt
| continue_stmt | continue_stmt
| block | block
} }
// --- basic statements --- // --- basic statements ---
@@ -75,10 +75,7 @@ while_stmt = {
} }
for_stmt = { for_stmt = {
"for" ~ "(" ~ (var_decl_no_semicolon | expr_stmt | ";") "for" ~ "(" ~ (var_decl_no_semicolon | expr_stmt | ";") ~ expr? ~ ";" ~ expr? ~ ")" ~ statement
~ expr? ~ ";"
~ expr? ~ ")"
~ statement
} }
// helper (same as var_decl but no trailing ;) // helper (same as var_decl but no trailing ;)
@@ -100,6 +97,9 @@ primary = {
postfix = { postfix = {
("." ~ identifier) ("." ~ identifier)
| ("(" ~ (expr ~ ("," ~ expr)*)? ~ ")") | ("(" ~ (expr ~ ("," ~ expr)*)? ~ ")")
| ("[" ~ expr ~ "]")
| ("++" | "--")
| (("+" | "-" | "*" | "/" | "%") ~ primary)
} }
expr = { expr = {
+1 -10
View File
@@ -1,12 +1,3 @@
import "fmt";
struct Point {
x: int,
y: int
}
function add(a: int, b: int): int { function add(a: int, b: int): int {
if (x) { itm.a + itm.b();
if (y) return 1;
}
} }