Back to BASICs

Overview


In the second part of the course, you’ll take the first steps towards creating a programming language. You’ll learn the basics of creating an interpreter for BASIC (Beginner’s All-purpose Symbolic Instruction Code), which was introduced in 1964. BASIC was one of the first high-level programming languages with a design goal of being easy to learn and use.

The manual for the original Dartmouth BASIC, which was developed at Dartmouth College, is available here. As you notice, there’s a lot to BASIC — thus, we will only focus on a subset of BASIC interpreter.

We’ll first try hacking the language together. Then, we’ll take a step back and learn about lexing and parsing, and how to structure the interpreter in a more sensible way.

The structure of this part is as follows.

  • BASIC Basics introduces the BASIC programming language, covering the structure and syntax of BASIC programs, starting from producing output and using variables ending with control flow structures.

  • Hacking away: Lines, printing, and variables shows how to start hacking together a BASIC interpreter, implementing functionality for reading and interpreting source code with variables and printing.

  • A Step Back: Lexers and Parsers takes a step back from hacking the interpreter together, introducing lexing and parsing. Lexing and parsing are essential for creating a programming language in a sensible manner.

  • Source to a Token Sequence with a Lexer shows how to create a lexer that converts a string of characters into a sequence of tokens that represent sequences of characters such as keywords, identifiers, and operators.

  • Tokens into Expressions and Statements with a Parser shows how to create a parser that transforms the list of tokens into statements with expressions.

  • Revised Interpreter combines the lexer and parser to create a revised version of the BASIC interpreter.

  • Adding Goto and If Statements shows how to add GOTO and IF statements to the BASIC interpreter.

Finally, at the end, the chapter Recap and Feedback provides a summary of the part and asks for feedback on the materials.