Welcome to Duncan White's Practical Software Development (PSD) Pages.

I'm Duncan White, an experienced and professional programmer, and have been programming for well over 30 years, mainly in C and Perl, although I know many other languages. In that time, despite my best intentions:-), I just can't help learning a thing or two about the practical matters of designing, programming, testing, debugging, running projects etc. Back in 2007, I thought I'd start writing an occasional series of articles, book reviews, more general thoughts etc, all focussing on software development without all the guff.

See all my Practical Software Development (PSD) Pages

picture of D. White


datadec: bringing Recursive (Inductive) Data Types to ANSI C.
Part 3: The internals of datadec - and how it was built.

The Input Language

Overall Structure of datadec

First Problem: Lexical Analysis of the Input

Second Problem: Parsing the token stream

Aside: Shortest Sentential Forms

Building a Recursive Descent Parser from our grammar

Third Problem: Building a Parse Tree

Fourth Problem: Building the Code Generator

Summary.

In this 3-part article, I've shown most of the process in which I designed and built the datadec tool to enable C programmers to use functional programming style Recursive Data Types freely in their programming. I find this ability enormously helpful in C programming, and strongly believe that it boosts one's C productivity tremendously. I haven't shown the complete code generator, and I've completely omitted the optimizer (which notices when an RDT happens to allow some useful optimizations in the C code generated, eg using NULL to represent an empty shape), but what I have shown gives an excellent flavour of the design and implementation, allowing you to see (a reconstruction of) the code as it was written.

datadec is a substantial tool, requiring about a fortnight's work to build, test and debug. But it's paid that investment back tenfold over the years. It uses the following "advanced" techniques:

These articles may either be viewed as a simple description of what I did to design and build this tool, or more generally as an example of the sort of tool building you can, and should, aspire to do yourself. A good programmer uses tools others have built, a great programmer knows when it's worth building your own tools, and how to do so.

Remember that you can download the full version of datadec from http://csgsoft.doc.ic.ac.uk/datadec. There are compilation and installation instructions inside the tarball - in most cases make install is all you need.

If these articles, or datadec itself, are useful to you, I'd be delighted if you'd drop me a quick email to let me know:-) -- Duncan White, 29th Dec 2014.


d.white@imperial.ac.uk
Back to the first part of this article Back to the second part of this article Back to PSD Top
Written: Nov-Dec 2014