Opertators
This commit is contained in:
+13
-13
@@ -37,15 +37,15 @@ block = { "{" ~ statement_list ~ "}" }
|
||||
statement_list = { statement* }
|
||||
|
||||
statement = _{
|
||||
expr_stmt
|
||||
| var_decl
|
||||
| if_stmt
|
||||
| while_stmt
|
||||
| for_stmt
|
||||
| return_stmt
|
||||
| break_stmt
|
||||
| continue_stmt
|
||||
| block
|
||||
expr_stmt
|
||||
| var_decl
|
||||
| if_stmt
|
||||
| while_stmt
|
||||
| for_stmt
|
||||
| return_stmt
|
||||
| break_stmt
|
||||
| continue_stmt
|
||||
| block
|
||||
}
|
||||
|
||||
// --- basic statements ---
|
||||
@@ -75,10 +75,7 @@ while_stmt = {
|
||||
}
|
||||
|
||||
for_stmt = {
|
||||
"for" ~ "(" ~ (var_decl_no_semicolon | expr_stmt | ";")
|
||||
~ expr? ~ ";"
|
||||
~ expr? ~ ")"
|
||||
~ statement
|
||||
"for" ~ "(" ~ (var_decl_no_semicolon | expr_stmt | ";") ~ expr? ~ ";" ~ expr? ~ ")" ~ statement
|
||||
}
|
||||
|
||||
// helper (same as var_decl but no trailing ;)
|
||||
@@ -100,6 +97,9 @@ primary = {
|
||||
postfix = {
|
||||
("." ~ identifier)
|
||||
| ("(" ~ (expr ~ ("," ~ expr)*)? ~ ")")
|
||||
| ("[" ~ expr ~ "]")
|
||||
| ("++" | "--")
|
||||
| (("+" | "-" | "*" | "/" | "%") ~ primary)
|
||||
}
|
||||
|
||||
expr = {
|
||||
|
||||
+1
-10
@@ -1,12 +1,3 @@
|
||||
import "fmt";
|
||||
|
||||
struct Point {
|
||||
x: int,
|
||||
y: int
|
||||
}
|
||||
|
||||
function add(a: int, b: int): int {
|
||||
if (x) {
|
||||
if (y) return 1;
|
||||
}
|
||||
itm.a + itm.b();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user