https://github.com/njmarko/mastermind-language
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.
https://github.com/njmarko/mastermind-language
bison cirilica dsl flex game grammar language mastermind serbian-cyrillic serbian-language skocko
Last synced: 9 days ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/njmarko/mastermind-language
- Owner: njmarko
- License: gpl-3.0
- Created: 2021-05-30T21:45:38.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-07-18T20:53:21.000Z (almost 5 years ago)
- Last Synced: 2025-03-02T15:54:12.285Z (over 1 year ago)
- Topics: bison, cirilica, dsl, flex, game, grammar, language, mastermind, serbian-cyrillic, serbian-language, skocko
- Language: C
- Homepage:
- Size: 2.05 MB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# 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](https://github.com/njmarko/mastermind-language/blob/main/%D0%BF%D1%80%D0%B0%D0%B2%D0%BE%D1%81%D0%BB%D0%B0%D0%B2%D0%BD%D0%B8-%D1%81%D0%BA%D0%BE%D1%87%D0%BA%D0%BE/dokumentacija/sw_38_2018_Marko_njegomir.pdf) that is located in ```mastermind-language/православни-скочко/dokumentacija/```.