Skip to content

Commit 438fecc

Browse files
committed
Add support for toml 1.1.0
1 parent 80cc29b commit 438fecc

File tree

4 files changed

+36
-11
lines changed

4 files changed

+36
-11
lines changed

docs/examples/templates.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ description = "Target templates"
2020
type = "executable"
2121
sources = ["src/templates.cpp"]
2222
compile-definitions = ["IS_APP"]
23-
2423
# Unlike interface targets you can also inherit properties
25-
[template.app.properties]
26-
CXX_STANDARD = "11"
27-
CXX_STANDARD_REQUIRED = true
24+
properties = {
25+
CXX_STANDARD = "11",
26+
CXX_STANDARD_REQUIRED = true,
27+
}
2828

2929
[target.app-a]
3030
type = "app"

tests/templates/cmake.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ description = "Target templates"
88
type = "executable"
99
sources = ["src/templates.cpp"]
1010
compile-definitions = ["IS_APP"]
11-
1211
# Unlike interface targets you can also inherit properties
13-
[template.app.properties]
14-
CXX_STANDARD = "11"
15-
CXX_STANDARD_REQUIRED = true
12+
properties = {
13+
CXX_STANDARD = "11",
14+
CXX_STANDARD_REQUIRED = true,
15+
}
1616

1717
[target.app-a]
1818
type = "app"

third_party/CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

third_party/toml11-3.8.1/toml/parser.hpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1847,6 +1847,15 @@ parse_inline_table(location& loc, const std::size_t n_rec)
18471847

18481848
// check if the inline table is an empty table = { }
18491849
maybe<lex_ws>::invoke(loc);
1850+
#ifdef TOML11_USE_UNRELEASED_TOML_FEATURES
1851+
// TOML 1.1.0: allow newlines in inline tables
1852+
while(loc.iter() != loc.end() &&
1853+
(*loc.iter() == '\r' || *loc.iter() == '\n'))
1854+
{
1855+
loc.advance();
1856+
}
1857+
maybe<lex_ws>::invoke(loc); // skip whitespace after newlines
1858+
#endif
18501859
if(loc.iter() != loc.end() && *loc.iter() == '}')
18511860
{
18521861
loc.advance(); // skip `}`
@@ -1914,13 +1923,28 @@ parse_inline_table(location& loc, const std::size_t n_rec)
19141923
else // `,` is found
19151924
{
19161925
maybe<lex_ws>::invoke(loc);
1926+
#ifdef TOML11_USE_UNRELEASED_TOML_FEATURES
1927+
// TOML 1.1.0: allow newlines after commas in inline tables
1928+
while(loc.iter() != loc.end() &&
1929+
(*loc.iter() == '\r' || *loc.iter() == '\n'))
1930+
{
1931+
loc.advance();
1932+
}
1933+
maybe<lex_ws>::invoke(loc); // skip whitespace after newlines
1934+
#endif
19171935
if(loc.iter() != loc.end() && *loc.iter() == '}')
19181936
{
1937+
#ifdef TOML11_USE_UNRELEASED_TOML_FEATURES
1938+
// TOML 1.1.0: trailing comma is allowed in inline tables
1939+
loc.advance(); // skip `}`
1940+
return ok(std::make_pair(retval, region(loc, first, loc.iter())));
1941+
#else
19191942
throw syntax_error(format_underline(
19201943
"toml::parse_inline_table: trailing comma is not allowed in"
19211944
" an inline table",
19221945
{{source_location(loc), "should be `}`"}}),
19231946
source_location(loc));
1947+
#endif
19241948
}
19251949
}
19261950
}

0 commit comments

Comments
 (0)