mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
toml: add quote details to ast.Quoted (#11997)
This commit is contained in:
@@ -691,9 +691,19 @@ pub fn (mut p Parser) bare() ast.Bare {
|
||||
|
||||
// quoted parse and returns an `ast.Quoted` type.
|
||||
pub fn (mut p Parser) quoted() ast.Quoted {
|
||||
// To get more info about the quote type and enable better checking,
|
||||
// the scanner is returning the literal *with* single- or double-quotes.
|
||||
mut quote := p.tok.lit[0]
|
||||
is_multiline := p.tok.lit.len >= 6 && p.tok.lit[1] == quote && p.tok.lit[2] == quote
|
||||
mut lit := p.tok.lit[1..p.tok.lit.len - 1]
|
||||
if is_multiline {
|
||||
lit = p.tok.lit[3..p.tok.lit.len - 3]
|
||||
}
|
||||
return ast.Quoted{
|
||||
text: p.tok.lit
|
||||
text: lit
|
||||
pos: p.tok.position()
|
||||
quote: quote
|
||||
is_multiline: is_multiline
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user