Parse C++17 nested namespace declarations

This is maybe not the most correct way to do it, but i dont think it misparses
any valid code.
This commit is contained in:
topisani 2017-12-20 18:15:31 +01:00
commit 76fb7dee43

View file

@ -18,13 +18,16 @@ namespace
{
detail::cxtokenizer tokenizer(context.tu, context.file, cur);
detail::cxtoken_stream stream(tokenizer, cur);
// [inline] namespace [<attribute>] <identifier> {
// [inline] namespace|:: [<attribute>] <identifier> [{]
auto is_inline = false;
if (skip_if(stream, "inline"))
is_inline = true;
skip(stream, "namespace");
// C++17 nested namespace declarations
if (!detail::skip_if(stream, "namespace"))
skip(stream, "::");
auto attributes = parse_attributes(stream);
// <identifier> {
@ -37,7 +40,9 @@ namespace
auto other_attributes = parse_attributes(stream);
attributes.insert(attributes.end(), other_attributes.begin(), other_attributes.end());
skip(stream, "{");
// C++17 nested namespace declarations
if (!detail::skip_if(stream, "::"))
skip(stream, "{");
auto result = cpp_namespace::builder(name.c_str(), is_inline);
result.get().add_attribute(attributes);