Interpreter

Last updated: Mar 27th, 2018

Introduction

The task of the interpreter is to execute the set of instructions provided in a cuneiform script. The interpreter contains three sections.

  1. Lexer
  2. Parser
  3. Interpreter

Lexer

In order for an interpreter to understand what to do with a program script, it first needs to break the script into components called tokens. A token is an object which has a type and a value.

The process of breaking apart the script into tokens is called lexical analysis. Therefore, the first step of the interpreter is to read the script and and convert it into a stream of tokens. The part of the interpreter that does this is called the lexical analyser, or lexer for short.

Parser

The process of finding the structure in the stream of tokens is called parsing. The part of the interpreter that does this job is called a parser.

In order to analyse complex Cuneiform programming language constructs, we need to build an intermediate representation (IR). The parser is responsible for creating this representation.

Interpreter

The structure provided by the parser is taken by the interpreter. This structure represents the set of instructions that needs to be executed. Therefore, the task of the interpreter is to execute the set of instructions as represented in the structure.

What's next?

The next section discusses the implementation details of the Lexer in Cuneiform.