By Andy Balaam
It sounds too difficult for mere mortals, but in principle a programming language interpreter is a relatively simple program. To demonstrate the main ideas involved, I wrote a very simple programming language called Cell (github.com/andybalaam/cell) and in this session we will walk through how it works.
Cell’s interpreter is written in Python, and the Cell language itself is designed to be as simple as possible to implement. This leads to some different trade-offs from most other languages, but hopefully leaves the main concepts intact.
We will walk through the code of Cell’s lexer (40 lines), parser (81 lines) and evaluator (92 lines) and on the way cover the main ideas you need to write your own language, including detecting the different symbols and literals the programmer wrote, building them up into a tree structure, evaluating the logic that is being represented, and writing a standard library of basic functions and structures.
This session is suitable for someone who has never thought of writing a programming language before. We will assume a working knowledge of Python code in places, but it should be simple enough to follow for anyone who regularly writes code in any language.