parser: minor cleanup of `stmt()` (#7573)

pull/7466/head
yuyi 2020-12-26 14:54:13 +08:00 committed by GitHub
parent 13f16b4a82
commit d66ed46486
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 10 deletions

View File

@ -679,19 +679,25 @@ pub fn (mut p Parser) stmt(is_top_level bool) ast.Stmt {
return p.return_stmt() return p.return_stmt()
} }
.dollar { .dollar {
if p.peek_tok.kind == .key_if { match p.peek_tok.kind {
return ast.ExprStmt{ .key_if {
expr: p.if_expr(true) return ast.ExprStmt{
expr: p.if_expr(true)
}
} }
} else if p.peek_tok.kind == .key_for { .key_for {
return p.comp_for() return p.comp_for()
} else if p.peek_tok.kind == .name { }
return ast.ExprStmt{ .name {
expr: p.vweb() return ast.ExprStmt{
expr: p.vweb()
}
}
else {
p.error_with_pos('unexpected \$', p.tok.position())
return ast.Stmt{}
} }
} }
p.error_with_pos('unexpected \$', p.tok.position())
return ast.Stmt{}
} }
.key_continue, .key_break { .key_continue, .key_break {
tok := p.tok tok := p.tok