Hi guys and gals,
I'm writing a file parser, which reads "source code -ish" text from files. The text is usually in this kind of format:
Module: {
Submodule: {
Property: Value
...
}
Submodule: {
}
}
Module: {
Property: Value
}
I've written a simple but hazardous reader that keeps reading until the next known name is found, but the problem in this approach is that if the known module / submodule / property name is not found, the program will read past the end and crash.
So, the question is: what is the best approach for this kind of reading and parsing? I thought of using a "brace stack", which would simply keep track of opening braces, so the reader will always know when a module ends. But that isn't enough, I am totally clueless about how to actually proceed and read the text safely and without any problems.
Thanks in advance for all the help and tips :)