Developing my XML project in C
So, these last couple of months I've been dabbling with C and XML, to get to know C better. Out of all of this there might also come a nice XML parser and writer that will be freely available for anyone to use.I wish I learned more C earlier, as a lot of things related to IT have fallen into place now that I've been forced to work on low-level stuff.
There have been quite a number of posts to comp.lang.c, and lots of useful information has been exchanged back and forth.
Anyway, the project is here:
https://github.com/morphex/smash_xml
I guess the bulk of the main code and tests are now around 25KB, which is quite a bit of code. One of the next steps is to create the main parsing loop, which will break down the XML file into its internal C representation. There will also have to be some data types created so that things work well.
One of the more interesting points that have come up is whether to use iteration or recursion when working with the internal representation.
In C, when you do a function call, things are pushed onto something called the stack. And with recursion, more and more things get pushed onto the stack, and if the recursion is deep enough, the stack is exhausted with unpredictable results.
So I think I'm opting for an iterative design in the C code, and using little if any recursion. I'm sure that's going to tick some people off, but having predictable and intelligible results when running the code is important for this project, because one can work with malicious input data.
Right now it feels like I'm past the most "painful" parts of learning C, and look forward to learning and writing more in the time to come.
[Permalink] [By morphex] [C & XML (Atom feed)] [13 Jul 00:51 Europe/Oslo]