Skip to content

Domain-specific language that generates messages from source code with logic-programming-like syntax, variables, functions and conditions.

License

Notifications You must be signed in to change notification settings

Dirakon/Message-Generator-DSL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contributors Forks Stargazers Issues MIT License


Message Generator DSL

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
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License

About The Project

Domain-specific language that generates messages from source code with logic-programming-like syntax, variables, functions and conditions.

(back to top)

Getting Started

To get a local copy up and running follow these simple example steps.

Prerequisites

You will need the following utilities installed globally:

Installation

  1. Clone the repo
    git clone https://github.com/Dirakon/Message-Generator-DSL.git
    cd Message-Generator-DSl
  2. Build project with globally installed spago
    spago build

(back to top)

Usage

Module usage

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

Language usage

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"
]

(back to top)

Roadmap

  • 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).

(back to top)

Contributing

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See license for more information.

(back to top)

About

Domain-specific language that generates messages from source code with logic-programming-like syntax, variables, functions and conditions.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages