Could it be possible to create a parser using regular expressions?
I was thinking on the design of a code completion plugin using regex with container classes.
For example:
FileArray - a container class that stores all the files.
The FileArray will use an array of file classes with members that indicate if header or source file, it's full path and name. Each file class would have other containers with it's contents, like includes, namespaces, defines, classes, structs, enums, typedef, unions, functions, variables etc...
So first we open a file as a stream search for includes like this "incomplete example": (#include)( )*([\"\<])(.*)([\"\>]) then parse it and remove that entry from the stream to continue parsing: namespaces "another incomplete or bad regexp" (namespace)([\r\n\t ])+([_0-9a-zA-Z])+([\r\n\t ])+([\{])+(.*)*([\}])+, also remove all the results found by the regexp from the stream an continue parsing other elements of c/c++.
Also the FileArray would have member functions to indicate the include paths to search for sources and includes.
I think it will be more easy to maintain since all the elements of the language would be divided in classes and the parsing made by the regexp engine.
There should be a class for every element like the ones mentioned above: functions, defines, variables, namespaces, blah blah blah with an interface that make some functions and members available to all, like file to parse, parsefunction, etc...
An example would be a class for Classes that is included as an array(container) on the FileArray class. The class would use some arrays(containers) of Function class, Variables class, Enum class, Struct class, Union class, etc...
I would like to work on something like this, but I don't know if it's a silly idea. More experienced programmers opinions would be nice.