Tag: "interpreter"

Recognizing Keywords

Most programming languages have a set of reserved keywords. The compiler or interpreter has to have a way to identify those keywords while the source code is being read. Here is how I do it for Cube.

Starting the Cube Project

Getting started on a new programming language and floundering around looking for how to structure the code. Fun, fun fun.

Interpreter Project: Inheritance

This is the last article in this series. The Lox language is feature complete, though far from actually complete. It is time to move on to something a little more realistic.

Interpreter Project: Classes

Classes were added to the language this time. Almost everything is in place, Class declarations, object initialization, properties, methods, references to 'this', etc. The only thing missing is Inheritance. That is added in the next section.

Interpreter Project: Resolving and Binding

This section was all about adding a Semantic Analysis step to the project. A Resolver is created to walk the Parse Tree and make note of where and how variables are accessed. That data is then provided to the Interpreter code to prevent a potential bug.

Interpreter Project: Functions

Function declarations and function calls. This looks like a real language now. Of course there is no standard library, no networking library, input / output library, etc. It is apparent to me now that the language definition is relatively easy. It is all the supporting libraries that constitute the bulk of the work.

Interpreter Project: Control Flow

Branching and looping, two very critical pieces of any Turing complete programming language, are now available. With all of the other work that has been done these features were quite easy to implement as well.

Interpreter Project: Statements

A lot of work went into this section. Statements were added to the grammar, as well as variable declarations, variable assignment and scopes.

Interpreter Project: Evaluating Expressions

The interpreter code is now in place and working. The foundation on which the rest of the Lox language will be created is done.

Interpreter Project: Parser

Getting deep into the Lox language now. The parser is where the syntax of a language lives.

Interpreter Project: Metaprogramming

A bit of a side-step here to generate the many classes needed to store the structure of the Lox code to be run. I have Ruby do the hard work for me.

Interpreter Project: Scanner

Finally some progress on actual interpreter code. The scanner code is in place and generating tokens. Nothing much happens with them other than being printed to stdout, but it is progress.

Interpreter Project Shakeup

I should have spent a bit more time with that interpreter book before committing to use it for this project. I would need much more time to learn Scheme than I want to spend.

Interpreter Project Boot

This is the second article in the Building an Interpreter series. The project is up and running on Github and some exercises from Chapter One of Essentials of Programming Languages have been written.

Building an Interpreter

An introduction to a series of articles on the creation of a little programming language. The goal is to just to have some fun with building a interpreter.