Domain-specific language that generates messages from source code with logic-programming-like syntax, variables, functions and conditions.
Explore the docs »
View example
·
Report Bug
·
Request Feature
Table of Contents
Domain-specific language that generates messages from source code with logic-programming-like syntax, variables, functions and conditions.
To get a local copy up and running follow these simple example steps.
You will need the following utilities installed globally:
- Clone the repo
git clone https://github.com/Dirakon/Message-Generator-DSL.git cd Message-Generator-DSl
- Build project with globally installed spago
spago build
After installation, you can easily access the builded version in output folder, for example, from node in the following manner:
import { initializeVariables, generateOneMessage } from '../output/Main/index.js'
let metaInfo = initializeVariables(sourceCode);
let exampleMessage = generateOneMessage(metaInfo)();
Alternatively, you could use this module as a submodule in another spago project, like in this example
The language supports functions(macros), variables, comments, assertions; here's code example with all of them:
>>> This is a comment
>>> This is the main function definition, which is the entry point. In this example, it references some variable.
>>> (Variables start with '$', and functions start with '#')
#Main = $Variable
>>> This is variable definition.
>>> ('|' separates different possible values the expression can take, '+' concatenates two expressions)
$Variable =
"some actual string"
| ($gender + " is " + $pronoun)
>>> This is multi-variable assignment. Think of it as destructuring assignment.
[$gender,$pronoun] = ["man","he"] | ["woman","she"]
>>> This is an assertion. It will filter out messages that were generated with variables not satisfying the condition.
$pronoun != "she"
The example code can generate the following messages:
[
"some actual string",
"man is he"
]
- Lift/add errors when applicable
- Document the functions
- Add fully functional pattern matching in assignments
- Fix message generation distribution with '|'
- Implement optimization for assertions depending on just one variable
- Add support for complex assertions (or/and)
- Add numeric values
- Add functions related to them
- Add boolean values
- Add functions related to them
- Add string-related functions
See the open issues for a full list of proposed features (and known issues).
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See license
for more information.