mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
v2: parse optionals
This commit is contained in:
parent
ac5c4e3203
commit
f1a0c2f1af
@ -144,7 +144,7 @@ fn (p mut Parser) fn_decl() ast.FnDecl {
|
||||
p.check(.rpar)
|
||||
// Return type
|
||||
mut typ := table.void_type
|
||||
if p.tok.kind in [.name, .lpar, .amp, .lsbr] {
|
||||
if p.tok.kind in [.name, .lpar, .amp, .lsbr, .question] {
|
||||
typ = p.parse_type()
|
||||
p.return_type = typ
|
||||
}
|
||||
|
@ -84,6 +84,9 @@ pub fn (p mut Parser) parse_type() table.Type {
|
||||
p.next()
|
||||
p.check(.dot)
|
||||
}
|
||||
if p.tok.kind == .question {
|
||||
p.next()
|
||||
}
|
||||
name := p.tok.lit
|
||||
match p.tok.kind {
|
||||
// func
|
||||
|
@ -368,7 +368,7 @@ pub fn (p mut Parser) name_expr() (ast.Expr,table.Type) {
|
||||
p.next()
|
||||
p.check(.dot)
|
||||
}
|
||||
else if p.tok.lit in ['strings'] {
|
||||
else if p.tok.lit in ['strings', 'strconv'] {
|
||||
p.next()
|
||||
p.check(.dot)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user