Friday, 10 September 2010

Time for flex and bison

A couple of weeks ago Phil lent me a book in which the creators of various programming languages are interviewed (Masterminds of Programming). I've only read a few of the interviews so far, but these have included the creators of C++, BASIC, Python and Forth. On the whole it's been fascinating reading and very relevant to this research project.

Fortunately, one theme that seems to be repeated is the idea that in general it's a 'good thing' for people to experiment with creating new programming languages. This of course is very encouraging for me to read, especially coming from these particular people.

As well as being full of discussion about generic issues that are useful for creating, disseminating, evolving and standardising a programming language, there have also been a few very specific bits of advice that I will try to follow, one of which is to use flex and bison when building your compiler.

Flex and bison are tools that help generate fast and correct C code for the first two steps of any text compilation process, namely: lexical analysis and grammar parsing. To date I've been hand crafting the C code for these two steps of my Textual Semprola compiler. I've known about flex and bison for a while, but always thought the cost of the learning curve and the code re-write were not quite worth it.

However, I'm about to go through a phase where I considerably extend and tinker with the syntax for Textual Semprola and so now I need to re-write this part of the code anyway. As I'm also reading more people sing the praises of flex and bison I've decided that this time I should push through the learning curve and start using these powerful little tools. The great thing is that once I've made the switch it should be easier to experiment with the syntax in the future.

One other thing to mention is that I've recently started some more client work. While this will no doubt delay the progress of this research project it does also help fund it!