{"id":21179222,"url":"https://github.com/nomocas/babelute","last_synced_at":"2026-01-07T00:24:08.607Z","repository":{"id":73936537,"uuid":"62996321","full_name":"nomocas/babelute","owner":"nomocas","description":"Internal Domain Specific (Multi)Modeling js framework","archived":false,"fork":false,"pushed_at":"2018-04-01T22:03:20.000Z","size":520,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-20T20:32:00.988Z","etag":null,"topics":["dialects","dsl","dsm","internal-dsl","lexicon","pragmatic-programming","semantic-web"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nomocas.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-07-10T11:54:27.000Z","updated_at":"2024-10-09T18:34:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"25e4fd2f-df0a-48a9-82f6-b67ee0635572","html_url":"https://github.com/nomocas/babelute","commit_stats":{"total_commits":209,"total_committers":1,"mean_commits":209.0,"dds":0.0,"last_synced_commit":"f60ff3144e03a7d15ac5dd9e3ed4d924b6202cbd"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nomocas%2Fbabelute","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nomocas%2Fbabelute/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nomocas%2Fbabelute/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nomocas%2Fbabelute/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nomocas","download_url":"https://codeload.github.com/nomocas/babelute/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234892694,"owners_count":18902907,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dialects","dsl","dsm","internal-dsl","lexicon","pragmatic-programming","semantic-web"],"created_at":"2024-11-20T17:29:21.321Z","updated_at":"2025-10-02T06:31:14.882Z","avatar_url":"https://github.com/nomocas.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Babelute.js\n\n\u003e __42__ \u0026asymp; _[ lexem( lexicon, name, arguments ), ... ]_\n\n### Internal Domain Specific (Multi)Modeling js framework\n\n[![Travis branch](https://img.shields.io/travis/nomocas/babelute/master.svg)](https://travis-ci.org/nomocas/babelute)\n[![bitHound Overall Score](https://www.bithound.io/github/nomocas/babelute/badges/score.svg)](https://www.bithound.io/github/nomocas/babelute)\n[![Coverage Status](https://coveralls.io/repos/github/nomocas/babelute/badge.svg?branch=master)](https://coveralls.io/github/nomocas/babelute?branch=master)\n[![dependecies](https://david-dm.org/nomocas/babelute.svg)](https://david-dm.org/)\n[![dev-dependencies](https://img.shields.io/david/dev/nomocas/babelute.svg)](https://david-dm.org/)\n[![npm-downloads](https://img.shields.io/npm/dm/babelute.svg)](https://npm-stat.com/charts.html?package=babelute)\n[![npm](https://img.shields.io/npm/v/babelute.svg)](https://www.npmjs.com/package/babelute)\n[![licence](https://img.shields.io/npm/l/babelute.svg)](https://spdx.org/licenses/MIT)\n[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-green.svg)](https://conventionalcommits.org)\n\nReally small, simple, incredibly powerful and super fast __Descriptive Internal DSLs__ tools.\n\n\n\u003e \"_A Babelut(t)e is a sort of long toffee flavoured with honey or vergeoise (demerara sugar) from [...] Flanders, Belgium_\".\n\n\u003e __Etymology__ : \"_[A french word that] is likely to come from the Flemish \"babbelen\", speaking a lot, and \"uit\", finished because when you eat the toffee, you cannot speak anymore (either because you are enjoying it or because you cannot open the mouth).[...]_\" - src : [wikipedia](https://en.wikipedia.org/wiki/Babelutte)\n\nBabelute.js core library (this lib) provides helpers to :\n- define and manage Internal DSLs for __modeling__ any kind of problems\n- with a simple (meta)grammar - based on Method Chaining - for writing __structured unambiguous \"sentences\"__ (called __babelutes__)\n- and to provide ways :\n\t- to manage __dictionaries of related lexems__ (called __lexicons__) that form DSL semantic fields and their __Internal Denotation__\n\t- to translate DSL sentences to other DSL sentences (by example through __dedicated bridge-DSLs__ with their own lexicon(s))\n\t- to interpret sentences in many context with specific __fine grained dedicated implementations__ (called __pragmatics__)\n\nThe idea is __really simple__ : lets __write structured sentence with some DSL to encapsulate information__ (aka modeling). Then use different \"interpretation\" engines to __do something with this information__ (aka implementations).\n\n## Core Libraries\n\n- [babelute](https://github.com/nomocas/babelute) (this lib) : provides Lexicon and Pragmatics base for writting DSLs.\n- [babelute-uus](https://github.com/nomocas/babelute-uus) : Universal Unambiguous Sentences proposal : Welcome in Sharing Era. For storing and sharing sentences.\n- [babelute-ldl](https://github.com/nomocas/babelute-ldl) : Babelute Lexicon Definition DSL (Sentences Schema) and its generators.\n\n## Understanding by real examples\n\nLow Level DSLs (Developement related domains) :\n- [aright-*](https://github.com/nomocas/aright-lexicon) : Objects and types validation DSL (ultra-fast, ultra-modular)\n- [htsl-*](https://github.com/nomocas/htsl-lexicon) : HTML5 DSL and its render engines. (modern, __one of the world's fastest__, one-way-binding templating (React philosophy))\n\nHigh Level DSLs (Human related domains) :\n- babelute-cooking : High Level Cooking DSL demo and its bunch of transformations and DSLs targets. (realease in summer 2017)\n\nPlease read [Designing a DSL](https://github.com/nomocas/babelute/blob/master/manual/designing-dsl.md) for more infos.\n\n## Theory background and development\n\nTheorical considerations are exposed [here](https://github.com/nomocas/babelute/blob/master/manual/theory.md) (work in progress).\n\n## Usage\n\n```\nnpm i babelute --save\n```\n\nThe aim is to define __Descriptive Internal DSLs__ :\n\n- Descriptive : Write what you want and not how to achieve it\n- Internal : made and handleable with pure host-language objects and syntax (v.s. an External DSL that has it's own particular syntax)\n- DSL : a bunch of related words (and so concepts) from a particular domain\n\nBy defining __Words as Functions__ that receive arguments :\n\n```javascript\n.aWords(arg1, arg2, ...)\n```\n\nAnd to write __structured sentences__ with them through __Method Chaining__ :\n\n```javascript\nh.this().is().a(h.sentence(true)) // this is an example : there is no such DSL... ;)\n```\n\nHow to get that :\n```javascript\n// my-dsl-lexicon.js\nimport babelute from 'babelute';\n\n/* A lexicon is where to store your words */\nconst lexicon = babelute.createLexicon('my-dsl');\n\n/* \nAtoms are words (of your DSL) that are not expressed with other words from the same lexicon (aka Domain).\nIn other words, they are words that should be expressed precisely \nwith some other domains concepts for particular contexts.\nIn other words, they need translation or implementation that are outside the scope of the current Domain.\n(see designing-a-dsl in babelute's doc for more infos)\n*/\nlexicon.addAtoms([\n\t'foo', // .foo(...args)\n\t'bar', // .bar(...args)\n\t'zoo', // .zoo(...args)\n\t'doo'  // .doo(...args)\n]);\n// don't worry, there is strict formal ways of defining allowed atoms arguments\n\n/* Compounds words are words (of your DSL) that are expressed with other words from the same lexicon */\nlexicon.addCompounds((h) =\u003e {\n\t// h is the lexicon's initializer (see below)\n\treturn {\n\t\tgoo(arg1, arg2) {\n\t\t\t// this is called the \"Internal Denotation\" of the compound lexem (here 'goo')\n\t\t\treturn this.foo(arg1).bar(arg2);\n\t\t},\n\t\tboo(...some){\n\t\t\treturn this.zoo(h.doo(some).foo('lollipop'));\n\t\t}\n\t};\n});\n\nexport default lexicon;\n```\n```javascript\nimport lexicon from 'my-dsl-lexicon';\n/* initializer are just a helper to start sentence with your lexicon */\nconst h = lexicon.initializer();\n\n/* then write sentences with your DSL to describe what you want */\nconst mySentence = h.goo('hello', 'world').boo('one', 'two', 'three').foo(true);\n```\n\nCompounds words (here `goo` and `boo`) are made of __atoms__ (or of other compounds words that are themselves made of atoms by recursivity), and so __sentences below are exactly equivalent__ (they hold the same lexems list and structure):\n```javascript\nconst mySentence = h.goo('hello', 'world').boo('one', 'two', 'three').foo(true);\n// is deeply equal to\nconst mySentence2 = \n\th.foo('hello')\n\t.bar('world')\n\t.zoo(\n\t\th.doo(['one', 'two', 'three'])\n\t\t.foo('lollipop')\n\t)\n\t.foo(true);\n```\n\nSo sentences are finally __always composed of atoms__ (those words that need implementation - see below).\n\nOf course, you are totally free to create any Internal DSL you want. Apart they should be \"Description Oriented\" (it is babelute's purpose), you could imagine whatever you want... Remember just that the aim is to define descriptive DSL to catch informations.\n\nSo, until here, we have just __described things__ (so we've stored information and knowledge in sentences - ok, imagine that we have ;) and we haven't defined yet any mean to interpret them and to make them useful.\n\nSo we need to define an \"interpretation\" engine which is called here a __pragmatics__ engine.\n\nThe cool fact is that, basically, as __sentences are always made of atoms__, we just need to provides implementation for our __atoms__, whatever the number of compounds words we have.\n\nLet's define a simple engine that use sentences made with `my-dsl` to decorate an object (called `subject` below) : \n```javascript\n// my-dsl-to-object-pragmatics.js\nconst myPragmas = {\n\tfoo(subject, args /* foo's args received in sentence */){\n\t\t// do something on subject with args\n\t\t// ...\n\t},\n\tbar(subject, args /* bar's args received in sentence */){\n\t\t// do something on subject with args\n\t\t// ...\n\t},\n\tzoo(subject, args /* zoo's args received in sentence */){\n\t\tsubject.zoo = {};\n\t\tif(args[0].__babelute__)\n\t\t\tthis.$output(args[0], subject.zoo);\n\t\telse\n\t\t\t...\n\t},\n\tdoo(subject, args /* doo's args received in sentence */){\n\t\t// do something on subject with args\n\t\t// ...\n\t},\n\n\t// by convention, the method's name used for interpretation start with a '$' \n\t$output(babelute, subject = {}){\n\t\tbabelute._lexems.forEach((lexem) =\u003e \n\t\t\tlexem.lexicon === 'my-dsl' \n\t\t\t\u0026\u0026 this[lexem.name]\n\t\t\t\u0026\u0026 this[lexem.name](subject, lexem.args) \n\t\t\t// simple mapping between lexem's name and own methods\n\t\t);\n\t\treturn subject;\n\t}\n};\n\nexport default myPragmas;\n```\n\n```javascript\nimport lexicon from 'my-dsl-lexicon';\nimport myDSLToObject from 'my-dsl-to-object-pragmatics';\n\nconst h = lexicon.initializer(), \n\tsubject = {},\n\tsentence = h.goo('hello', 'world').boo(['one', 'two', 'three']);\n\nmyDSLToObject.$output(sentence, subject);\n```\n\nStraight forward...\n\nAgain, of course you are totally free to interpret sentences exactly as you want. There is no constraints. And you could imagine many differents output kind and usage (from simple Facade for manipulating objects states, to full Code Generation Tools). Imagination is the limit.\n\n\nFinally, lets define a dialect of `my-dsl` :\n\n```javascript\n// my-dsl-dialect-lexicon.js\nimport myDSLLexicon from 'my-dsl-lexicon';\n\nconst myDialectLexicon = myDSLLexicon.createDialect('my-dsl-dialect');\n\nmyDialectLexicon.addCompounds((h) =\u003e ({\n\tmyNewWord(...){\n\t\treturn this.foo('...').goo(...);\n\t},\n\tmyOtherNewWord(...){\n\t\treturn this.boo('...').bar(...).doo();\n\t},\n\t...\n}));\n\nexport default myDialectLexicon;\n```\n```javascript\nimport lexicon from 'my-dsl-dialect-lexicon';\nconst h = lexicon.initializer();\nconst mySentence = h.myOtherNewWord('hello', 'world')...;\n\n...\n\n// of course always usable with pragmatics that work with my-dsl\n\nimport myDSLToObject from 'my-dsl-to-object-pragmatics';\n\nconst decoratedObject = myDSLToObject.$output(mySentence);\n```\n\nPlease read [Designing a DSL](https://github.com/nomocas/babelute/blob/master/manual/designing-dsl.md) for more infos.\n\n## Licence\n\nThe [MIT](http://opensource.org/licenses/MIT) License\n\nCopyright 2016-2017 (c) Gilles Coomans \u003cgilles.coomans@gmail.com\u003e\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnomocas%2Fbabelute","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnomocas%2Fbabelute","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnomocas%2Fbabelute/lists"}