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,20 +679,26 @@ pub fn (mut p Parser) stmt(is_top_level bool) ast.Stmt {
return p.return_stmt()
}
.dollar {
if p.peek_tok.kind == .key_if {
match p.peek_tok.kind {
.key_if {
return ast.ExprStmt{
expr: p.if_expr(true)
}
} else if p.peek_tok.kind == .key_for {
}
.key_for {
return p.comp_for()
} else if p.peek_tok.kind == .name {
}
.name {
return ast.ExprStmt{
expr: p.vweb()
}
}
else {
p.error_with_pos('unexpected \$', p.tok.position())
return ast.Stmt{}
}
}
}
.key_continue, .key_break {
tok := p.tok
line := p.tok.line_nr