satya-das/cppparser

Parsing the nested namespace definitions fails

agladilin opened this issue · 3 comments

The code below causes error.

namespace my::ns1 { }

The error:

Error: Unexpected '::', while in context=ctxGeneral(1), found at line#7
namespace my::
            ^
Segmentation fault

Please note that this option is a part of c++17 standard.
https://en.cppreference.com/w/cpp/language/namespace

This is now supported with commit 49e2b6b. Please try again with latest update.

The object model changed. As of earlier version I had several nested namespace objects. Now I get a single namespace with name my::ns1.
However, this is quite a satisfactory option for me. Works like a charm! Thank you so much!

The object model changed.

Indeed, this can be a problem. But as far as parsing is concerned, the best option is to parse like this.
I do see the requirement of improvements for CppProgram::nameLookup() and related functions when a C++17 style nested namespace definition is parsed as one namespace.

If a different object model is a must then that can be constructed from the current object model in a very straight forward ways.