1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

parser: minor cleanup of check() (#7333)

This commit is contained in:
yuyi 2020-12-15 11:31:34 +08:00 committed by GitHub
parent da9588c1a5
commit bfa8e4bf86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -396,15 +396,13 @@ fn (mut p Parser) check(expected token.Kind) {
// for p.tok.kind in [.line_comment, .mline_comment] {
// p.next()
// }
if p.tok.kind != expected {
if p.tok.kind == .name {
p.error('unexpected name `$p.tok.lit`, expecting `$expected.str()`')
} else {
p.error('unexpected `$p.tok.kind.str()`, expecting `$expected.str()`')
}
return
if p.tok.kind == expected {
p.next()
} else if p.tok.kind == .name {
p.error('unexpected name `$p.tok.lit`, expecting `$expected.str()`')
} else {
p.error('unexpected `$p.tok.kind.str()`, expecting `$expected.str()`')
}
p.next()
}
// JS functions can have multiple dots in their name: