Skip to content

Interpret an esoteric programming language's code and handle errors.

License

Notifications You must be signed in to change notification settings

key6oardWarrior/EsoLang-Interpreter

Repository files navigation

Esoteric Interpreter

Interpret an esoteric programming language's code and handle errors.

Background

BF is an esoteric programming language created in 1993 by Urban Müller. The language only has eigth commands, but it is fully Turing complete. BF has no practical uses, but it does challenge programmers, while testing the bounds of computer science.

How to Code in BF

  1. '>' Forward pointer. Tell C++ to point to the memory block that is infront of the current memory block
  2. '<' Backward pointer. Tell C++ to point to the memory block that is behind the current memory block
  3. '.' Print. Tell C++ to print what is in the memory block that C++ is currently pointing too
  4. ',' User input. Tell C++ to take user input
  5. '+' Increment. Tell C++ to increment the memory block by 1
  6. '-' Decrement. Tell C++ to decrement the memory block by 1
  7. '[' Start a loop. Tell C++ where the start a loop is located. When a loop starts over it will go to wherever the '[' char is located
  8. ']' End a loop. Tell C++ where the end of a loop is located. A Loop will only end if the value of the current memory block is 0 and the current char being read is '['

Rules

  1. This interpreter does not read white spaces
  2. Loops must start and end on the same line
  3. There are 30,000 memory blocks
  4. Each memory block is initialized with the value 0
  5. Each memory block cannot be more than 127
  6. Each memory block cannot be less than -128
  7. Attemping to go above 127, or below -128, will result in an error
  8. If during user input a user enter a std::string each char will be put in a memory block of it's own
  9. The BF code must be stored in a .bf file

Example of Good BF Code

image

Enviorment

  1. Built in Visual Studio 2022
  2. C++ Language standard: ISO C++20 Standard (/std:c++20)
  3. C Language standard: ISO C17 (2018) Standard (/std:c17)
  4. Complied on the x64 platform

Note:

When running the unit test ensure that Visual Studio Code 2022's configuration manager is set to Debug, or else not all the assert functions will not be called.