Skip to content

Extensible programming language built with JavaScript

License

Notifications You must be signed in to change notification settings

tautvilas/lingu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lingu

Lingu is extensible programming language that is operating with domain abstractions and not their implementation details.

This technology is WIP and exploring ideas similar to concept programming and intentional programming.

Example usage

Check out TodoMVC app implemetation with Lingu here.

Lingu in a nutshell

Lingu sentences are divided into these categories:

  1. Data structure definitions
  2. Action sentences
  3. Query definitions
  4. Translations

Each action sentence is constructed out of words. Each word is either plugin, handler, evaluator, value, query, selector or datatype.

Authors

Language components

Plugins

(words, parseState, appState) => ({mutateState: (s) => s, parseState, cursor})

context [query]

on [handler ,handler ,]

add [datatype]

with [datatype value]

remove [query]

update [query]

set [datatype value]

clear [selector]

focus [selector]

show [selector]

hide [selector]

if [value] .

else .

setInputValue [selector value]

log [value]

Handlers

Lingu.handlers.keyUp = (words) => {
  Lingu.domEventHandlers.push({
    selector: words[0],
    handler: (event) => {
      const parseState = {
        event: event
      };
      Lingu.methods.parseActionLine(words.slice(1), parseState);
    },
    event: 'keyup'
  });
};

firstRun

triggered on first run of the app

change [datatype]

triggered when change in data is detected

click [selector]

triggered on element click

blur [selector]

triggered on input element blur

missClick [selector]

triggerred when click happens outside element

doubleClick [selector]

triggered on element double click

keyUp [selector]

triggered on keyUp in input

escape [selector]

triggered on escape key in input

enter [selector]

triggered on enter key in input

Evaluators

(words, parseState, appState) => ({value: [], parseState, cursor})

from [selector]

returns value from selected elements

empty [selector]

evaluates to true if selected elements have empty value, otherwise evaluates to false

is [query value]

evaluates to true if query returns items that equal value, otherwise evaluates to false

has [query]

evaluates to true if query returns any items, otherwise evaluates to false

not [value]

evalutes to true if value is false, otherwise evaluates to false

valueOf [query]

converts query result to value

Extending the language

You can extend language by adding your own custom plugins, evaluators and handlers to Lingu.plugins, Lingu.evaluators and Lingu.handlers.

Running unit tests

$ npm install
$ npm run test

Running e2e tests

$ npm install
$ node server.js
$ java -jar selenium-standalone.jar
$ npm run e2e

About

Extensible programming language built with JavaScript

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published