parent
c780de6282
commit
e3e5bef139
|
@ -0,0 +1,13 @@
|
||||||
|
fn main() {
|
||||||
|
a, b := true, true
|
||||||
|
|
||||||
|
// a
|
||||||
|
if a || b {
|
||||||
|
println('hi')
|
||||||
|
}
|
||||||
|
|
||||||
|
// a
|
||||||
|
if a || b {
|
||||||
|
println('hi')
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
fn main() {
|
||||||
|
a, b := true, true
|
||||||
|
|
||||||
|
if a || // a
|
||||||
|
b {
|
||||||
|
println('hi')
|
||||||
|
}
|
||||||
|
|
||||||
|
if a /* a */ || b {println('hi')}
|
||||||
|
}
|
|
@ -21,6 +21,9 @@ pub fn (mut p Parser) check_expr(precedence int) ?ast.Expr {
|
||||||
if !p.pref.is_fmt {
|
if !p.pref.is_fmt {
|
||||||
p.eat_comments()
|
p.eat_comments()
|
||||||
}
|
}
|
||||||
|
if p.inside_if_cond {
|
||||||
|
p.if_cond_comments << p.eat_comments()
|
||||||
|
}
|
||||||
inside_array_lit := p.inside_array_lit
|
inside_array_lit := p.inside_array_lit
|
||||||
p.inside_array_lit = false
|
p.inside_array_lit = false
|
||||||
defer {
|
defer {
|
||||||
|
@ -350,6 +353,9 @@ pub fn (mut p Parser) check_expr(precedence int) ?ast.Expr {
|
||||||
return node
|
return node
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if p.inside_if_cond {
|
||||||
|
p.if_cond_comments << p.eat_comments()
|
||||||
|
}
|
||||||
return p.expr_with_left(node, precedence, is_stmt_ident)
|
return p.expr_with_left(node, precedence, is_stmt_ident)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -481,6 +487,9 @@ fn (mut p Parser) infix_expr(left ast.Expr) ast.Expr {
|
||||||
precedence := p.tok.precedence()
|
precedence := p.tok.precedence()
|
||||||
mut pos := p.tok.pos()
|
mut pos := p.tok.pos()
|
||||||
p.next()
|
p.next()
|
||||||
|
if p.inside_if_cond {
|
||||||
|
p.if_cond_comments << p.eat_comments()
|
||||||
|
}
|
||||||
mut right := ast.empty_expr()
|
mut right := ast.empty_expr()
|
||||||
prev_expecting_type := p.expecting_type
|
prev_expecting_type := p.expecting_type
|
||||||
if op in [.key_is, .not_is] {
|
if op in [.key_is, .not_is] {
|
||||||
|
|
|
@ -128,7 +128,13 @@ fn (mut p Parser) if_expr(is_comptime bool) ast.IfExpr {
|
||||||
} else {
|
} else {
|
||||||
prev_guard = false
|
prev_guard = false
|
||||||
p.comptime_if_cond = true
|
p.comptime_if_cond = true
|
||||||
|
p.inside_if_cond = true
|
||||||
cond = p.expr(0)
|
cond = p.expr(0)
|
||||||
|
p.inside_if_cond = false
|
||||||
|
if p.if_cond_comments.len > 0 {
|
||||||
|
comments << p.if_cond_comments
|
||||||
|
p.if_cond_comments = []
|
||||||
|
}
|
||||||
p.comptime_if_cond = false
|
p.comptime_if_cond = false
|
||||||
}
|
}
|
||||||
comments << p.eat_comments()
|
comments << p.eat_comments()
|
||||||
|
|
|
@ -36,6 +36,7 @@ mut:
|
||||||
inside_test_file bool // when inside _test.v or _test.vv file
|
inside_test_file bool // when inside _test.v or _test.vv file
|
||||||
inside_if bool
|
inside_if bool
|
||||||
inside_if_expr bool
|
inside_if_expr bool
|
||||||
|
inside_if_cond bool
|
||||||
inside_ct_if_expr bool
|
inside_ct_if_expr bool
|
||||||
inside_or_expr bool
|
inside_or_expr bool
|
||||||
inside_for bool
|
inside_for bool
|
||||||
|
@ -90,6 +91,7 @@ mut:
|
||||||
should_abort bool // when too many errors/warnings/notices are accumulated, should_abort becomes true, and the parser should stop
|
should_abort bool // when too many errors/warnings/notices are accumulated, should_abort becomes true, and the parser should stop
|
||||||
codegen_text string
|
codegen_text string
|
||||||
struct_init_generic_types []ast.Type
|
struct_init_generic_types []ast.Type
|
||||||
|
if_cond_comments []ast.Comment
|
||||||
}
|
}
|
||||||
|
|
||||||
__global codegen_files = []&ast.File{}
|
__global codegen_files = []&ast.File{}
|
||||||
|
|
Loading…
Reference in New Issue