Skip to content

Commit dc6c2a0

Browse files
authored
toml: reach 100% TOML v1.0.0 compliance with the official test suite (#26203)
1 parent aba5919 commit dc6c2a0

3 files changed

Lines changed: 12 additions & 12 deletions

File tree

‎vlib/toml/checker/checker.v‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -471,9 +471,9 @@ pub fn (c &Checker) check_quoted(q ast.Quoted) ! {
471471
lit := q.text
472472
quote := q.quote.ascii_str()
473473
triple_quote := quote + quote + quote
474-
if q.is_multiline && lit.ends_with(triple_quote) {
474+
if q.is_multiline && lit.ends_with(triple_quote) && !lit.ends_with('\\' + triple_quote) {
475475
return error(@MOD + '.' + @STRUCT + '.' + @FN +
476-
' string values like "${lit}" has unbalanced quote literals `q.quote` in ...${c.excerpt(q.pos)}...')
476+
' string values like "${lit}" has unbalanced quote literals `${quote}` in ...${c.excerpt(q.pos)}...')
477477
}
478478
c.check_quoted_escapes(q)!
479479
c.check_utf8_validity(q)!
@@ -526,7 +526,7 @@ fn (c &Checker) check_quoted_escapes(q ast.Quoted) ! {
526526
// Rest of line must only be space chars from this point on
527527
for {
528528
ch_ := s.next()
529-
if ch_ == scanner.end_of_text || ch_ == `\n` {
529+
if ch_ == `\n` {
530530
break
531531
}
532532
if !(ch_ == ` ` || ch_ == `\t`) {

‎vlib/toml/parser/parser.v‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,7 @@ pub fn (mut p Parser) array() ![]ast.Value {
11881188
}
11891189
}
11901190
}
1191-
1191+
p.ignore_while(all_formatting)
11921192
match p.tok.kind {
11931193
.boolean {
11941194
arr << ast.Value(p.boolean()!)
@@ -1241,9 +1241,13 @@ pub fn (mut p Parser) array() ![]ast.Value {
12411241
.rsbr {
12421242
break
12431243
}
1244+
.bare {
1245+
return error(@MOD + '.' + @STRUCT + '.' + @FN +
1246+
' unexpected value "${p.tok.lit}". Array values should be quoted (with " or \') in this (excerpt): "...${p.excerpt()}..."')
1247+
}
12441248
else {
1245-
error(@MOD + '.' + @STRUCT + '.' + @FN +
1246-
' could not parse "${p.tok.kind}" "${p.tok.lit}" ("${p.tok.lit}") in this (excerpt): "...${p.excerpt()}..."')
1249+
return error(@MOD + '.' + @STRUCT + '.' + @FN +
1250+
' unexpected token "${p.tok.kind}" "${p.tok.lit}" in this (excerpt): "...${p.excerpt()}..."')
12471251
}
12481252
}
12491253
}

‎vlib/toml/tests/toml_lang_test.v‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,13 @@ const hide_oks = os.getenv('VTEST_HIDE_OK') == '1'
1515
const no_jq = os.getenv('VNO_JQ') == '1'
1616

1717
// Kept for easier lookup and handling of future updates to the tests.
18-
// NOTE: entries in this list are valid TOML that the parser should work with, but currently does not.
18+
// NOTE: entries in this list, except `do_not_remove`, are valid TOML that the parser should work with, but currently does not.
1919
const valid_exceptions = [
2020
'do_not_remove',
21-
'string/escapes.toml',
22-
'string/multiline-quotes.toml',
2321
]
24-
// NOTE: entries in this list are tests of invalid TOML that should have the parser fail, but currently does not.
22+
// NOTE: entries in this list, except `do_not_remove`, are tests of invalid TOML that should have the parser fail, but currently does not.
2523
const invalid_exceptions = [
2624
'do_not_remove',
27-
'string/multiline-escape-space-02.toml',
28-
'string/missing-quotes-array.toml',
2925
]
3026
const valid_value_exceptions = [
3127
'do_not_remove',

0 commit comments

Comments
 (0)