https://github.com/jeffnyman/voxam
Text Adventure Parser Experiment
https://github.com/jeffnyman/voxam
Last synced: 2 months ago
JSON representation
Text Adventure Parser Experiment
- Host: GitHub
- URL: https://github.com/jeffnyman/voxam
- Owner: jeffnyman
- License: cc-by-sa-4.0
- Created: 2025-03-30T10:04:35.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2025-03-31T08:03:58.000Z (3 months ago)
- Last Synced: 2025-03-31T08:30:39.781Z (3 months ago)
- Language: C++
- Size: 48.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![]()
Text Adventure Parser Experiment
Works onWindows,
macOS and
Linux.
---
The goal of this repo is to hold a series of experiments that show how to gradually build up a text adventure style parser in C++. This is a vanity repo that is letting me re-learn some long-forgotten C and C++ as well as get me ready for writing a Z-Machine interpreter.
In case you're wondering about the title, the word "voxam" refers to a spell that could be cast in the game _Zork: Grand Inquisitor_. The spell's name referred to the ability to "separate the energies of different magics." Since the parser idea is about separating a command into a series of understood tokens, I felt there was a least a little corollary here.
## π’ Prerequisites
Make sure you have a C++ compiler that can handle C++20. See the implementation section below.
## β‘ Execution
You can compile Voxam with the following:
```sh
make
```If you want to compile and run, you can do the following:
```sh
make run
```If you have [cppcheck](https://cppcheck.sourceforge.io/) installed, you can execute that with this:
```sh
make check
```The configuration for cppcheck is in the Makefile.
## π» Implementation
I will be using C++20 for this project.
- Full C++20 support was completed in GCC 11 (released April 2021). GCC 12, 13, and 14 have even better conformance and optimizations. If you're using a recent Linux distro or have updated your toolchain, you're almost certainly on a version that handles C++20 fine.
- Clang 11 (released September 2020) had most C++20 features, with more support in Clang 14 (released March 2022). In 2025, Clang 17 or 18 is likely becoming the norm in many environments (via LLVM updates or Xcode). With the exception of some module issues, these versions seem solid.
- Microsoft Visual Studio added full C++20 support in Visual Studio 2019 version 16.10 (released mid-2021). By 2025, Visual Studio 2022 is standard, and C++20 is pretty rock-solid there.
- Smaller or embedded compilers, such as for specific microcontrollers, might lag in implementation, but the big three (GCC, Clang, MSVC) cover most general-purpose development.
As of March 2025, at the time I write this, C++20 is widely supported by all major compilers in their recent versions. If you're using a reasonably up-to-date toolchain (GCC 11+, Clang 14+, or VS 2022), you're good to go. Even older setups from 2022 and 2023 likely support C++20 fully. Or, at least, fully enough for the relatively limited features I will be using.
## π¨βπ» Jeff's Principles of Coding
- Embrace small code.
- Abstraction encourages clarity.
- No computation is too small to be put into a helper function.
- No expression is too simple to be given a name.
- Small code is more easily seen to be obviously correct.
- Code thatβs more obviously correct can be more easily composed.
- Be willing to trade elegance of design for practicality of implementation.
- Embrace brevity, but do not sacrifice readability. Concise, not terse.
- Prefer elegance over efficiency where efficiency is less than critical.In my C++ context, this is manifesting in some specifics.
- **Consistency** in function signatures and parameter passing.
- **Separation of concerns** to ensure each function has a single responsibility.
- **Reusability** and **flexibility** via template-based approaches.
- **Clarity** and **readability** with meaningful names and simple logic.
- **Safety** and **robustness** with careful handling of edge cases.
- **Efficiency** in avoiding unnecessary copies or redundant operations.
- **Extensibility** of the design to add new functionalities easily.
- **Modularity** for easy maintenance and testing.## β License
The code used in this project is licensed under the [CC-BY-SA-4.0 license](https://github.com/jeffnyman/voxam/blob/main/LICENSE).