Flow control

This commit is contained in:
Greg Shuflin 2021-11-12 00:27:06 -08:00
parent 92c6d7f311
commit 5af42d0828
2 changed files with 7 additions and 1 deletions

View File

@ -35,8 +35,14 @@ peg::parser! {
rule statement_kind() -> StatementKind =
__ import:import() { StatementKind::Import(import) } /
__ decl:declaration() { StatementKind::Declaration(decl) } /
__ flow:flow() { StatementKind::Flow(flow) } /
__ expr:expression() { StatementKind::Expression(expr) }
rule flow() -> FlowControl =
"continue" { FlowControl::Continue } /
"break" { FlowControl::Break } /
"return" _ expr:expression()? { FlowControl::Return(expr) }
rule import() -> ImportSpecifier =
"import" _ path_components:path_components() suffix:import_suffix()? {
ImportSpecifier {

View File

@ -1292,7 +1292,7 @@ fn flow_control() {
return 10;
}"#;
assert_ast!(
assert_ast2!(
source,
vec![fn_decl(
Signature { name: rc("test"), operator: false, type_anno: None, params: vec![] },