Fix minor grammar
This commit is contained in:
@@ -16,6 +16,7 @@ export = { "public" }
|
|||||||
mutable = { "mut" }
|
mutable = { "mut" }
|
||||||
sharp = _{ "#" }
|
sharp = _{ "#" }
|
||||||
var_decl = { type_expr ~ mutable? ~ identifier }
|
var_decl = { type_expr ~ mutable? ~ identifier }
|
||||||
|
semicolon = { ";" }
|
||||||
|
|
||||||
// ================= TOP LEVEL =================
|
// ================= TOP LEVEL =================
|
||||||
|
|
||||||
@@ -74,17 +75,17 @@ statement = _{
|
|||||||
|
|
||||||
// --- basic statements ---
|
// --- basic statements ---
|
||||||
|
|
||||||
expr_stmt = { expr ~ ";" }
|
expr_stmt = { expr ~ semicolon }
|
||||||
|
|
||||||
return_stmt = { "return" ~ expr? ~ ";" }
|
return_stmt = { "return" ~ expr? ~ semicolon }
|
||||||
|
|
||||||
break_stmt = { "break" ~ ";" }
|
break_stmt = { "break" ~ semicolon }
|
||||||
|
|
||||||
continue_stmt = { "continue" ~ ";" }
|
continue_stmt = { "continue" ~ semicolon }
|
||||||
|
|
||||||
var_decl_statement = { var_decl ~ ("=" ~ expr)? ~ ";" }
|
var_decl_statement = { var_decl ~ ("=" ~ expr)? ~ semicolon }
|
||||||
|
|
||||||
assign_statement = { expr ~ "=" ~ expr ~ ";" }
|
assign_statement = { expr ~ "=" ~ expr ~ semicolon }
|
||||||
|
|
||||||
else_if = { "else" ~ "if" ~ "(" ~ expr ~ ")" ~ statement }
|
else_if = { "else" ~ "if" ~ "(" ~ expr ~ ")" ~ statement }
|
||||||
|
|
||||||
@@ -135,7 +136,7 @@ macro_call_px = { "!" ~ "(" ~ macro_inner_v* ~ ")" }
|
|||||||
struct_px = { "{" ~ (struct_field_decl ~ ("," ~ struct_field_decl)*)? ~ ","? ~ "}" }
|
struct_px = { "{" ~ (struct_field_decl ~ ("," ~ struct_field_decl)*)? ~ ","? ~ "}" }
|
||||||
index_px = { "[" ~ expr ~ "]" }
|
index_px = { "[" ~ expr ~ "]" }
|
||||||
binary_px = { bin_op ~ expr }
|
binary_px = { bin_op ~ expr }
|
||||||
bin_op = { "+" | "-" | "*" | "/" | "%" | "==" | "!=" | "<" | ">" | "<=" | ">=" }
|
bin_op = { "<=" | ">=" | "==" | "!=" | "+" | "-" | "*" | "/" | "%" | "<" | ">" }
|
||||||
struct_field_decl = { identifier ~ ":" ~ expr }
|
struct_field_decl = { identifier ~ ":" ~ expr }
|
||||||
|
|
||||||
prefix = {
|
prefix = {
|
||||||
|
|||||||
+6
-1
@@ -7,7 +7,7 @@ public struct ApiCall {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
ApiCall call = ApiCall { x: 10, y: 12 };
|
ApiCall mut call = ApiCall { x: 10, y: 12 };
|
||||||
|
|
||||||
if (call.x == 20) {
|
if (call.x == 20) {
|
||||||
println!("= 20");
|
println!("= 20");
|
||||||
@@ -19,5 +19,10 @@ void main() {
|
|||||||
println!("= unknown");
|
println!("= unknown");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (call.x <= 40) {
|
||||||
|
call.x = call.x - 1;
|
||||||
|
println!("while");
|
||||||
|
}
|
||||||
|
|
||||||
println!("{call:?}");
|
println!("{call:?}");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user