1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

toml: support checking and decoding quoted keys (#12552)

This commit is contained in:
Larpon
2021-11-23 15:59:07 +01:00
committed by GitHub
parent 0779b5fd8e
commit 1be6aed16e
3 changed files with 14 additions and 7 deletions

View File

@ -1061,16 +1061,25 @@ pub fn (mut p Parser) key() ?ast.Key {
' key expected .bare, .underscore, .number, .quoted or .boolean but got "$p.tok.kind"')
}
// A small exception that can't easily be done via `checker`
// since the `is_multiline` information is lost when using the key.text as a
// A few small exceptions that can't easily be done via `checker` or `decoder` *after* the
// main table has been build since information like `is_multiline` is lost when using the key.text as a
// V `map` key directly.
if p.config.run_checks {
if key is ast.Quoted {
if key is ast.Quoted {
if p.config.run_checks {
quoted := key as ast.Quoted
if quoted.is_multiline {
return error(@MOD + '.' + @STRUCT + '.' + @FN +
' multiline string as key is not allowed. (excerpt): "...${p.excerpt()}..."')
}
chckr := checker.Checker{
scanner: p.scanner
}
chckr.check_quoted(quoted) ?
}
if p.config.decode_values {
mut quoted := key as ast.Quoted
decoder.decode_quoted_escapes(mut quoted) ?
key = ast.Key(quoted)
}
}