In the last chapter, we saw how to parse text files—in particular, how to program source files in a simple programming language. Text files aren't the only thing you could need to parse—several kinds of system software need to parse binary files (such as binary executables, multimedia files, and inter-process communication messages).
In this chapter, we will look at how to cope with the need for parsing binary files and how the nom library can be used to ease this task. First, we will look at how to parse and interpret a very simple machine language without using an external library, and then how the nom library can be used to ease this task.
To do this, we will cover the following topics:
- Introducing a very simple machine language using only 16-bit words
- Writing a couple of programs in this language
- Writing a parser...