mirror of
https://github.com/vlang/v.git
synced 2025-09-09 23:39:39 -04:00
This commit is contained in:
parent
ec5eeb57b2
commit
261a4fb31b
@ -83,8 +83,11 @@ fn (mut p Parser) check_expr(precedence int) !ast.Expr {
|
|||||||
p.tok.pos())
|
p.tok.pos())
|
||||||
} else if p.tok.kind == .question && p.peek_tok.kind == .amp {
|
} else if p.tok.kind == .question && p.peek_tok.kind == .amp {
|
||||||
node = p.prefix_expr()
|
node = p.prefix_expr()
|
||||||
} else if p.inside_for_expr && p.tok.kind == .name && p.tok.lit[0].is_capital()
|
} else if p.inside_for_expr && p.tok.kind == .name && ((p.tok.lit[0].is_capital()
|
||||||
&& p.peek_tok.kind == .lcbr && p.peek_token(2).kind in [.rcbr, .name] {
|
&& p.peek_tok.kind == .lcbr && p.peek_token(2).kind in [.rcbr, .name])
|
||||||
|
|| (p.inside_array_lit && p.peek_tok.kind == .dot && p.peek_token(2).kind == .name
|
||||||
|
&& p.peek_token(2).lit[0].is_capital() && p.peek_token(3).kind == .lcbr
|
||||||
|
&& p.peek_token(4).kind in [.rcbr, .name])) {
|
||||||
node = p.struct_init(p.mod + '.' + p.tok.lit, .normal, false)
|
node = p.struct_init(p.mod + '.' + p.tok.lit, .normal, false)
|
||||||
} else if p.is_generic_name() && p.peek_tok.kind == .lcbr
|
} else if p.is_generic_name() && p.peek_tok.kind == .lcbr
|
||||||
&& p.peek_token(2).kind == .rcbr && p.peek_token(2).line_nr == p.tok.line_nr {
|
&& p.peek_token(2).kind == .rcbr && p.peek_token(2).line_nr == p.tok.line_nr {
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
import v.ast
|
||||||
|
|
||||||
|
fn test_main() {
|
||||||
|
for idx, s in [ast.Struct{
|
||||||
|
scoped_name: '1'
|
||||||
|
}, ast.Struct{
|
||||||
|
embeds: [ast.Type(2), 3]
|
||||||
|
}, ast.Struct{
|
||||||
|
is_typedef: true
|
||||||
|
is_union: true
|
||||||
|
is_heap: true
|
||||||
|
}, ast.Struct{
|
||||||
|
is_minify: ast.Struct{
|
||||||
|
is_anon: true
|
||||||
|
}.is_generic
|
||||||
|
is_shared: true
|
||||||
|
}, ast.Struct{
|
||||||
|
has_option: true
|
||||||
|
}] {
|
||||||
|
println('${idx} ${s}')
|
||||||
|
if idx == 0 {
|
||||||
|
assert s.scoped_name == '1'
|
||||||
|
} else if idx == 1 {
|
||||||
|
assert s.embeds == [ast.Type(2), 3]
|
||||||
|
} else if idx == 2 {
|
||||||
|
assert s.is_typedef == true
|
||||||
|
assert s.is_union == true
|
||||||
|
assert s.is_heap == true
|
||||||
|
} else if idx == 3 {
|
||||||
|
assert s.is_minify == false
|
||||||
|
assert s.is_shared == true
|
||||||
|
} else if idx == 4 {
|
||||||
|
assert s.has_option == true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user