OnceUponATime (.ouat)
An innovative and immersive programming language that allows you to write code through a natural, poetic and engaging narration, automatically transformed into modern C++.
About the Project
OUAT revolutionizes programming by fully integrating narrative art into software development. By structuring algorithmic logic as stories, OUAT allows developers, writers and artists to create programs that literally tell stories.
The project aims to bridge the gap between literary and computer arts, fostering mutual understanding and stimulating multidisciplinary creativity.
Key Features
Natural Syntax
Write your programs as authentic and living stories.
C++ Compilation
Each script is instantly converted into clear and efficient C++ code.
Flow Control
Intuitively manage conditions (`If...then`) and loops (`While`, `For each`).
Reusable Functions
Define and invoke easily narrative instruction blocks.
Organic Comments
Annotate your scripts with `Remark:`, `Note:` or `Comment:`.
Interactivity
Incorporate choices and random elements to enrich the story.
Example of a .ouat script
Here is an overview of the narrative syntax of the language through a complete example.
Once upon a time. Remark: The adventure begins in the mysterious kingdom of Æther. The hero has a strength of 10 and magic is 5. The sky was vibrant with strange colors until the sudden appearance of a dragon. Fate was uncertain, and the hero's heart beat with heroic intensity. If the dragon awakens then display "The dragon roars with mystical fury." Define the function invokeShield as display "A luminous shield protects the hero from imminent danger." return endfunction. call invokeShield. else if the dragon is friendly then display "A surprising alliance forms between the hero and the dragon, promising a new future." else display "Conflict erupts violently, and dark shadows descend." While magic is greater than 0 narrate "Sparks dance in the deep darkness." Magic subtract 1 equals magic. endwhile. endif. For each companion in the squad do tell "A brave companion joins the legendary adventure." endfor. The hero choose "Which path should be followed now?". Random fate leans towards courage or caution. Commentary: End of the script. The story ends.
Installation and Usage
Prerequisites
You will need the g++ compiler (supporting C++17 or higher), CMake and Git.
Compiler the Compiler
git clone https://github.com/TheoBaudoinLighting/OnceUponATime.git cd OnceUponATime mkdir build && cd build cmake .. make
Utilisation
To compile your `.ouat` script into C++, then execute the generated program:
# Compiler un script .ouat ./bin/ouat_compiler examples/my_story.ouat -o output/scene.cpp # Compile and execute the C++ program g++ output/scene.cpp -o output/scene ./output/scene
Project Status and Warning
This project is delivered as is. It is an artistic and conceptual exploration of a narrative programming language. As such, no guarantee of performance, stability or complete functionality is provided.
The compiler is functional for the provided examples, but may not handle all cases. Use it as an experiment and a source of inspiration. Contributions to improve its robustness are welcome.