babelute-uus

0.3.0 • Public • Published

babelute-uus : Universal Unambiguous (DSL) Sentences proposal

Travis branch bitHound Overall Score Coverage Status npm npm-downloads licence dependecies dev-dependencies

Babelute sentences (de)serialization.

Welcome in Sharing Era.

UUS examples :

  • #my-lexic: foo() bar("zoo")
  • #my-lexic: foo() bar("zoo", #my-other-lexicon: goo(true) lollipop([1, 2, 3]))

or beautified :

#my-lexic:
foo()
bar("zoo", 
    #my-other-lexicon: 
    goo(true) 
    lollipop([1, 2, 3])
)
boo({ some:true })

Pure Functional Host-Language Agnostic Internal DSL Form.

Much more expressive, clean and terse than JSON or XML (UUS could be seen as a super-set of both).

Ok, actual Host-Language Agnosticism will be achieved when there will be UUS parser in other Host Language than javascript. Feel free to contribute... ;)

This implementation offer :

  • Small, Clean, and Fast parser based on elenpi (an internal DSL for LL(1) parser generation).
  • Ultra Fast serialisation (2 or 3 times faster than equivalent JSON output).

Install

yarn add babelute babelute-uus

Usage

import babelute from 'babelute'; // or var babelute = require('babelute');
import 'babelute-uus'; // or require('babelute-uus');
 
const lexicon = babelute.createLexicon('my-lexic');
 
lexicon.addAtoms(['foo', 'goo', 'bar', 'lollipop']);
 
const h = lexicon.initializer();
 
const sentence = h.foo()
.bar("zoo", 
    h.goo(true) 
    .lollipop([1, 2, 3])
)
.boo({ some:true });
 
/*
 *** SERIALIZATION
 */
 
const string = sentence.$toUUS();
// #my-lexic:foo()bar("zoo",goo(true)lollipop([1,2,3]))
 
const string2 = sentence.$toUUS({ beautify:true });
/*
#my-lexic:
foo()
bar("zoo",
    goo(true)
    lollipop([1, 2, 3])
)
*/
 
/*
 *** DESERIALIZATION
 */
 
babelute.registerLexicon(lexicon); // to make it accessible globally to parser
const parsedSentence = babelute.fromUUS(string /* or string2 */);
// parsedSentence is the same as initial sentence

More on it soon. Mainly :

  • Why it's a super-set of JSON.
  • Why it's a super-set of XML.
  • Lexicon Scope Management (xml namespace equivalent)
  • Atomic and FirstLevel Form
  • UUS Form of Lexicon-Definition-Language
  • Sentences validation

Licence

The MIT License

Copyright 2017 (c) Gilles Coomans

Permission 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:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE 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.

Package Sidebar

Install

npm i babelute-uus

Weekly Downloads

0

Version

0.3.0

License

MIT

Last publish

Collaborators

  • nomocas