mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: number attributes (#9835)
This commit is contained in:
parent
431d806dcf
commit
c026d8b6f3
@ -13,6 +13,7 @@ pub:
|
||||
is_comptime_define bool // [if name]
|
||||
arg string // [name: arg]
|
||||
is_string_arg bool // [name: 'arg']
|
||||
is_number_arg bool // [name: 123]
|
||||
pos token.Position
|
||||
}
|
||||
|
||||
|
@ -1512,6 +1512,7 @@ fn (mut p Parser) parse_attr() ast.Attr {
|
||||
mut arg := ''
|
||||
is_string := p.tok.kind == .string
|
||||
mut is_string_arg := false
|
||||
mut is_number_arg := false
|
||||
if is_string {
|
||||
name = p.tok.lit
|
||||
p.next()
|
||||
@ -1532,6 +1533,10 @@ fn (mut p Parser) parse_attr() ast.Attr {
|
||||
// `name: arg`
|
||||
if p.tok.kind == .name {
|
||||
arg = p.check_name()
|
||||
} else if p.tok.kind == .number {
|
||||
arg = p.tok.lit
|
||||
is_number_arg = true
|
||||
p.next()
|
||||
} else if p.tok.kind == .string { // `name: 'arg'`
|
||||
arg = p.tok.lit
|
||||
is_string_arg = true
|
||||
@ -1545,6 +1550,7 @@ fn (mut p Parser) parse_attr() ast.Attr {
|
||||
is_comptime_define: is_comptime_define
|
||||
arg: arg
|
||||
is_string_arg: is_string_arg
|
||||
is_number_arg: is_number_arg
|
||||
pos: apos.extend(p.tok.position())
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user