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:
parent
8eef31bba1
commit
76fb7dee43
1 changed files with 8 additions and 3 deletions
|
|
@ -18,13 +18,16 @@ namespace
|
||||||
{
|
{
|
||||||
detail::cxtokenizer tokenizer(context.tu, context.file, cur);
|
detail::cxtokenizer tokenizer(context.tu, context.file, cur);
|
||||||
detail::cxtoken_stream stream(tokenizer, cur);
|
detail::cxtoken_stream stream(tokenizer, cur);
|
||||||
// [inline] namespace [<attribute>] <identifier> {
|
// [inline] namespace|:: [<attribute>] <identifier> [{]
|
||||||
|
|
||||||
auto is_inline = false;
|
auto is_inline = false;
|
||||||
if (skip_if(stream, "inline"))
|
if (skip_if(stream, "inline"))
|
||||||
is_inline = true;
|
is_inline = true;
|
||||||
|
|
||||||
skip(stream, "namespace");
|
// C++17 nested namespace declarations
|
||||||
|
if (!detail::skip_if(stream, "namespace"))
|
||||||
|
skip(stream, "::");
|
||||||
|
|
||||||
auto attributes = parse_attributes(stream);
|
auto attributes = parse_attributes(stream);
|
||||||
|
|
||||||
// <identifier> {
|
// <identifier> {
|
||||||
|
|
@ -37,7 +40,9 @@ namespace
|
||||||
auto other_attributes = parse_attributes(stream);
|
auto other_attributes = parse_attributes(stream);
|
||||||
attributes.insert(attributes.end(), other_attributes.begin(), other_attributes.end());
|
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);
|
auto result = cpp_namespace::builder(name.c_str(), is_inline);
|
||||||
result.get().add_attribute(attributes);
|
result.get().add_attribute(attributes);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue