OnceUponATime (.ouat)
An experimental narrative syntax compiled to a small C++ subset. The project explores language design, parsing and the relationship between textual structure and executable logic.
- Type
- Personal language-design experiment
- Role
- Language design and compiler implementation
- Implementation
- C++17 lexer, parser, AST and code generator
- Output
- Readable C++ for a deliberately limited grammar
What the experiment explores
I wanted to test whether story-like sentences could map to a predictable executable structure. The useful part of the project is not a claim that prose should replace conventional code; it is the exercise of defining a grammar, resolving ambiguity and making the translation visible.
Implemented
- Tokenization for the documented
.ouatvocabulary - A recursive-descent parser for selected narrative constructs
- An abstract syntax tree with explicit ownership
- C++17 generation for variables, conditions, loops and functions
- Selected records and basic image-output statements
- Unit and integration tests for lexer, parser, AST and code generation
Small syntax example
The prologue and epilogue delimit the script; the body maps a limited set of narrative phrases to explicit control flow.
Once upon a time.
The dragon is awake.
If the dragon is awake then
display "The dragon roars".
else
display "The attic is quiet".
endif.
The story ends.
Current boundaries
- Language scope
- The implementation covers a small documented grammar. It is not presented as a general-purpose programming language.
- Parsing
- The parser handles supported examples, but structured recovery from malformed input is not implemented.
- Generated code
- The C++ output is useful for inspecting the translation. No performance or optimization claim is made.
- Tooling
- There is no dedicated editor, debugger, profiler or production toolchain around the language.
What I learned
I learned that natural-looking syntax still needs strict rules to remain predictable. Readable generated C++ made the translation easier to inspect and debug. Small examples exposed grammar limitations faster than expanding the language too early.
Credits and confidentiality
- Production
- Personal experimental project
- Exact role
- Language design, lexer, parser, AST, code generation and tests
- Work by others
- The C++ compiler, Visual Studio toolchain and test dependencies are third-party technologies.
- Confidentiality
- No NDA. The implementation is public on GitHub.