Skip to content

Language for the mastermind game in C with Flex and Bison. C++ program is used to generate zero-byte files, and to decode them. Make tool is used to create the compiler and run replays.

License

Notifications You must be signed in to change notification settings

njmarko/mastermind-language

Repository files navigation

mastermind-language

Illustration 1 - Victory in the mastermind game.

Requirements

To run the program you need the following things:

  • Linux - Tested on Ubuntu 20.04
  • GCC
  • G++
  • Flex
  • Bison
  • GNU make
  • Serbian (Cyrillic with guillemets) language

Running the program

Make tool has the necessary commands to use the program. Just position yourself in the православни-скочко folder where the make file is located, and run the commands in the terminal:

  • make - creates the necessary files needed to play the mastermind game.
  • ./скочко - run the mastermind game.
  • You need Serbian Cyrillic language to use the program.

    Illustration 2 - Serbian Cyrillic is required.

    • Enter нова игра or започни to start the new game at any point.
    • To input signs use either sign names separated by white space or corresponding sign numbers.

      Illustration 3 - Inputing the combination.

    • End the game at any time by typing крај.
  • To watch the replay of the game you played, type make replay REPLAY=igra1. Name of the game you played in this example is igra1 where number 1 is the number of the game since multiple games can be played in succession.
  • make help can be used to list all the supported commands.
  • make clean can be used to clean all the files generated by the make command.

Motivation for mastermind language

The goal was to create a completely new language that has a purpose and that is useful. Since there are already a lot of programming languages that cover different needs, I decided to instead create a language that is specific for one domain/task. Language for the mastermind game was particularly interesting to me because of the stark differences of this language to the classic programming languages:

  • User does not write the language to the file and then compile it. Instead, the user gets the feedback for inputs in real-time, and based on that information, he can continue to create appropriate inputs. For the feedback, I created a colorized visualization of the mastermind game in the terminal. Appropriate messages are also displayed as feedback.
  • Since there is no file, there is also no end-of-file token, so the user can input the language indefinitely. The game ends when the user inputs the designated end token.
  • The language has no syntax errors. This allows the language to be parsed indefinitely because no input can break the program, and therefore an infinite number of mastermind games can be played. For this to work, grammar was designed so that no syntax errors can occur.
  • Language requires Serbian Cyrillic letters to be used. This was a challenge because the Flex tool does not support UTF8 characters in regular expressions. Instead, every UTF8 character had to be interpreted like a word that contains multiple characters. This is because Flex regex interprets UTF8 characters that are 3 bytes in size like 3 ASCII characters that are 1 byte in size each.
  • Generated i386 assembly code represents a replay of the played mastermind game.
  • Generated code would have 0 lines of code. Also, these generated files are 0 bytes in size.

Explanation with more details (in Serbian) can be found in pdf that is located in mastermind-language/православни-скочко/dokumentacija/.

About

Language for the mastermind game in C with Flex and Bison. C++ program is used to generate zero-byte files, and to decode them. Make tool is used to create the compiler and run replays.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published