I have a log file in the form:
begin; x1
begin; y1
end; y1
begin; z1
begin; z2
end; z2
end; z1
end;x1
I am looking to parse this file into a data structure that could look like the following:
x1 >
y1
z1 >
z2
so the x1 event contains the y1 & z1 events and the z1 event contains the z2 event.
Is there a standard algorithm that might be of use in this situation?
I’m thinking perhaps recursion might be able to help me here by branching on each ‘begin’ statement to correctly parse all sub-events. Any suggestions would be gratefully received.
Edit:
The ultimate goal for this will be to display the events on a GUI within a hierarchical ListView-type component. I am hoping that by being able to display the log files like this it will be possible to better visualize sequence of events within my system.
I would go for a recursive descent parser.
etc.
Here we have