C-Programming-Tools Fifth Lecture: released 3rd June 2021


d.white@imperial.ac.uk

I have just released the fifth and final lecture of my first year lectures on C Tools, building a toolbox of useful tools, and the craft skills to use them effectively, in order to make C programming easier.

This final lecture covers the following single topic: Making Code Generator Tools easier - autogenerating parser and lexers.

  • Building little languages easily by using parser generator and lexer generator tools (eg. the combination of Yacc/Bison, Lex/Flex, and datadec for Abstract Syntax Trees).
  • Worked example of a tiny Haskell Subset, presented as a series of step by step examples. After parsing and building a parse tree, we do semantic checks, and then write an interpreter, and finally, we replace the interpreter with a Code generator which spits out C syntax, so without noticing it we end up writing a (tiny subset of) Haskell to C compiler.
  • Better yet, we only write 14% of the code and our tools write the rest.
  • Thoughts on an alternative parsing technique.
  • Conclusions: use tools as much as you can. choose ones you like; become expert in their use. build a toolkit of trusted tools. Build your own tools where necessary. Define your own little languages, use parser generator tools to help.


Here are the lecture materials (slides and associated examples - of which there are many):


d.white@imperial.ac.uk
Updated: June 2021 
Back to my C Tools Lectures Pages.