v.parser: support for [if expr], part 1

Enables bootstrapping.
Supports the new [if x?] syntax, without using it.
pull/10493/head
Delyan Angelov 2021-06-17 10:29:14 +03:00
parent 6a19a13812
commit c2a7a84c72
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
1 changed files with 6 additions and 0 deletions

View File

@ -1524,6 +1524,12 @@ fn (mut p Parser) parse_attr() ast.Attr {
kind = .comptime_define
p.next()
p.check(.name)
// TODO: remove this check after bootstrapping
// it is only for compatibility with the new
// [if user_defined?] syntax.
if p.tok.kind == .question {
p.next()
}
name = p.prev_tok.lit
} else if p.tok.kind == .string {
name = p.tok.lit