match grammar
This commit is contained in:
@@ -98,6 +98,7 @@ statement_list = { statement* }
|
||||
|
||||
statement = _{
|
||||
expr_stmt
|
||||
| match_stmt
|
||||
| var_decl_statement
|
||||
| assign_statement
|
||||
| if_stmt
|
||||
@@ -144,6 +145,12 @@ for_stmt = {
|
||||
"for" ~ "(" ~ identifier ~ "in" ~ expr ~ ")" ~ statement
|
||||
}
|
||||
|
||||
match_item = { pattern ~ "=>" ~ block }
|
||||
|
||||
match_stmt = {
|
||||
"match" ~ "(" ~ expr ~ ")" ~ match_item*
|
||||
}
|
||||
|
||||
// ================= EXPRESSIONS =================
|
||||
tuple_type = { "(" ~ (type_expr ~ ("," ~ type_expr)*)? ~ ")" }
|
||||
path_type = { static_path ~ ("<" ~ (type_expr ~ ("," ~ type_expr)*)? ~ ">")? }
|
||||
|
||||
+2
-1
@@ -1,9 +1,10 @@
|
||||
mod my_class;
|
||||
use <my_class::MyClass>;
|
||||
use <my_class::MyEnum>;
|
||||
|
||||
void main() {
|
||||
var my_class = new MyClass("World");
|
||||
my_class.greet();
|
||||
|
||||
var (x, y) = (10, 20);
|
||||
match (MyEnum::Tuple(10)) {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user