mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: fix showing error position for pratt.v (#6997)
This commit is contained in:
parent
159abd4727
commit
6da6a082c7
@ -52,7 +52,7 @@ pub fn (mut p Parser) expr(precedence int) ast.Expr {
|
|||||||
match p.peek_tok.kind {
|
match p.peek_tok.kind {
|
||||||
.name { return p.vweb() }
|
.name { return p.vweb() }
|
||||||
.key_if { return p.if_expr(true) }
|
.key_if { return p.if_expr(true) }
|
||||||
else { p.error('unexpected $') }
|
else { p.error_with_pos('unexpected `$`', p.peek_tok.position()) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.chartoken {
|
.chartoken {
|
||||||
@ -191,10 +191,11 @@ pub fn (mut p Parser) expr(precedence int) ast.Expr {
|
|||||||
node = p.struct_init(true) // short_syntax: true
|
node = p.struct_init(true) // short_syntax: true
|
||||||
} else if p.tok.kind == .name {
|
} else if p.tok.kind == .name {
|
||||||
p.next()
|
p.next()
|
||||||
lit := if p.tok.lit != '' { p.tok.lit } else { p.tok.kind.str() }
|
s := if p.tok.lit != '' { '`$p.tok.lit`' } else { p.tok.kind.str() }
|
||||||
p.error('unexpected `$lit`, expecting `:`')
|
p.error_with_pos('unexpected $s, expecting `:`', p.tok.position())
|
||||||
} else {
|
} else {
|
||||||
p.error('unexpected `$p.tok.lit`, expecting struct key')
|
p.error_with_pos('unexpected `$p.tok.lit`, expecting struct key',
|
||||||
|
p.tok.position())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p.check(.rcbr)
|
p.check(.rcbr)
|
||||||
@ -230,7 +231,8 @@ pub fn (mut p Parser) expr(precedence int) ast.Expr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
p.error('expr(): bad token `$p.tok.kind.str()`')
|
p.error_with_pos('invalid expression: unexpected $p.tok.kind.str() token',
|
||||||
|
p.tok.position())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return p.expr_with_left(node, precedence, is_stmt_ident)
|
return p.expr_with_left(node, precedence, is_stmt_ident)
|
||||||
|
Loading…
Reference in New Issue
Block a user