I have a configuration format similar to *.sln format, so take the following as an example:
DCOM Productions Configuration File, Format Version 1.0
BeginSection:Global
GlobalKeyA = AnswerOne
.: Stores the global configuration key
:: for the application. This key is used
:: to save the current state of the app.
:: as well as prevent lockups
GlobalKey3 = AnswerTwo
.: Secondary Key. See above setting
GlobalKeyC = AnswerThree
BeginSection: UpdateSystem
NestedKeyA = One
NestedKeyB = Two
NestedKeyC = { A set of multiline data
where we will show how
to write a multiline
paragraph }
NestedKeyD = System.Int32, 100
EndSection
EndSection
BeginSection:Application
InstallPath = C:\Program Files\DCOM Productions\BitFlex
EndSection
I know that I will need a recursive function probably that takes a segment of text as a parameter so, for example, pass an entire section to it, and recursively parse it that way.
I just can't seem to get my head around how to do this. Each section can potentially have more child sections. It's like an Xml document.. I'm not really asking for code here, just a methodology about how to go about parsing a document like this.
I was thinking about using the tabs (specifies the index) to determine which section I am working with, but this would fail if the document was not tabbed (formatted) correctly. Any better thoughts?