Parsing A C++ Source File

So I have been looking into writing my own, very simple, compiler, assembler and linker. As I am, of course, a big fan of C++ I thought that would be a good place to start.

To everyone more experienced than me you probably know this was a terrible, terrible mistake.

The contexual nature of C++ means that to parse it I have ended up having to create a complicated "scope" tree. I then have to try and assign what type of scope this scope is. So this means that from the top of the "Scope" tree I have to walk down and assign based on source before the scope whether the scope is a function, a namespace, a class, a struct or default scope.

To determine this I also have to determine what a function is. This sounds trivial but it can be a bit deceptive. And people seem to want to use regular expressions and knowing the types before hand makes this easier but since we can declare types within functions this needs a few passes. It is complicated and a faff. Too much of a faff for Sunday morning relaxing code.

The long story short is that I made some good progress getting it there and my operations tree for the actually code part is working well but I am shelving that for now and I will start with implementing my own very simple language...