A Guide to Python Parser Packages.

Photo by David Clode on Unsplash

A Guide to Python Parser Packages.

TLDR: This article delves into the realm of esoteric programming languages and provides an overview of Python parser packages used to write and run code in these unique languages. Learn about the history of esoteric languages, the benefits of exploring them, and how to use Python parser packages to experiment with these languages for fun and creativity.


Programming languages are constantly evolving, with new languages being developed and existing ones being updated. While mainstream languages like Java, C++, and Python dominate the programming landscape, there is also a growing interest in exploring esoteric programming languages.

Esoteric programming languages are designed to be unconventional, challenging, and often humorous. They are not intended for practical use but rather as a form of artistic expression or a way to challenge traditional programming paradigms.

In this article, we will explore some of the most popular esoteric programming languages and show you how to use Python parser packages to create interpreters for them.

Brainf**k

Brainf**k is one of the most well-known esoteric programming languages, with its minimalist syntax consisting of just eight commands. It was created in 1993 by Urban Müller and is often used as a benchmark for evaluating the difficulty of implementing an interpreter for a programming language.

The Brainf**k language operates on an array of memory cells, each initially set to zero. The eight commands operate on the memory cells, with > and < moving the data pointer right and left, + and - incrementing and decrementing the cell at the pointer, . outputting the value at the pointer as an ASCII character, and, reading a single character of input, and storing it in the current cell.

To create an interpreter for Brainf**k in Python, we can use the pyparsing package. This package provides a powerful framework for building parsers in Python, allowing us to define the language's grammar and generate an abstract syntax tree (AST) that we can then use to execute the code.

Whitespace

Whitespace is another popular esoteric programming language created in 2003 by Edwin Brady and Chris Morris. As the name suggests, the language uses only whitespace characters (spaces, tabs, and linefeeds) to define the program's structure.

Whitespace has three types of commands: stack manipulation, arithmetic, and heap access. Stack manipulation commands include pushing and popping values to and from the stack; arithmetic commands include addition, subtraction, multiplication, and division, and heap access commands allow the program to store and retrieve values from a heap of memory.

To create an interpreter for Whitespace in Python, we can use the pyparsing package to parse the whitespace characters and generate an AST. We can then traverse the AST and execute the corresponding commands.

Shakespeare Programming Language

The Shakespeare Programming Language (SPL) was created in 2001 by Karl Hasselström and Jon Åslund. It is unique in that it is designed to read like a play, with the code consisting of characters speaking in iambic pentameter.

The language operates on the character stack and the integer stack. Each character represents a command, with the characters speaking to each other to exchange information and manipulate the stacks.

To create an interpreter for SPL in Python, we can use the pyparsing package to parse the code and generate an AST. We can then traverse the AST and execute the corresponding commands using Python lists to represent the stacks.

Whitespace and Shakespeare Programming Language are just two examples of the many esoteric programming languages. While they may not be practical for everyday use, they can be a fun and challenging way to explore different programming paradigms and learn new skills.

In conclusion, we have explored some of the most popular esoteric programming languages and shown you how to use Python parser packages to create interpreters for them. While these languages may not have practical applications, they can be a fun way to explore different programming paradigms and challenge yourself as a programmer.