Write an interpreter for a tiny language
Build a small programming language with variables, arithmetic, if, while and functions: a lexer, a parser that builds a tree, and an evaluator that runs it.
What this proves to recruiters
- You can build a complex system from scratch.
- You understand trees, recursion and parsing deeply.
- You can explain how real languages work.
Skills you will use
- Parsing
- Recursion
- Trees
- Language design
What you need
Nothing to buy: this project only needs a computer and the free software below.
Free software
- Any language you like
- “Crafting Interpreters” (free online)
Steps
- Write the lexer: turn text into tokens like NUMBER, IDENT, PLUS and LPAREN.
- Write a recursive-descent parser that respects precedence (× before +).
- Build the syntax tree and print it to check the structure.
- Write the evaluator that walks the tree, with an environment for variables.
- Add if, while and functions with their own scopes.
- Write programs in your language: FizzBuzz, factorial and a prime sieve.
Make it stand out
- Add closures.
- Compile to bytecode and run it on a small virtual machine.
Put it on your resume
Built an interpreter for a small language (lexer, recursive-descent parser, tree-walking evaluator) with functions, scopes and loops.
Replace each [x] with a number you measured. Real numbers make a line believable.
Keep going
This project fits stage 2, “Data structures and algorithms”, of the Software engineering roadmap. See also how freshers get into associate software engineer jobs.