1.0.0 • Published 3 years ago

jli-jelly v1.0.0

Weekly downloads
-
License
ISC
Repository
gitlab
Last release
3 years ago
  • JLI

** Table of Contents :toc:

About JLI is a Lisp inspired Array based Programming Language. Pronounced like jelly, JLI seems like the worst way of spelling jelly, but JLI actually represents Javascript Lisp. Roadmap 4/11

JLI was just started, its thus not in a usable state although you can read and print data. Below you can see the current status of the project. The number of planned features might change in the feature as we continue adding stuff

*** TODO Console Output 2/4 - X print - format - princ - X terpri

*** DONE Console Input 1/1 CLOSED: 2020-08-17 Mon 16:00 - X read

** TODO MATH 6/19 - X + - X - - X - X / - X rem - X mod - expt - sqrt - exp - log - eq - floor - ceiling - max - min - oddp - evenp - numberp - null

*** DONE Extras 1/1 CLOSED: 2020-08-17 Mon 16:00 - X progn

*** DONE Logical Operators 8/8 CLOSED: 2020-11-21 Sat 21:05 - X = - X <= - X >= - X < - X > - X not - X and - X or

*** TODO Equality 0/3 - eq - equal - equalp

*** TODO Conditionals 1/5 - X if - cond - case - when - unless

*** TODO Variables 0/1 - defvar - let

*** DONE DataTypes 2/2 CLOSED: 2020-11-21 Sat 21:05 - X Symbols - X Boolean

*** TODO Functions 0/1 - defunc

* TODO Documentation Documentation

*** Importing JLI is shipped as a module meaning you can just import it as a module #+BEGIN_SRC javascript // import JLI import { JLI } from './jli.js';

// import JLI, Default Command set and Default Kit import { JLI, JLI_COMMANDS, JLI_DEFAULTS } from './jli.js'; #+END_SRC JLI ships with a simple lisp integration that can be loaded and initialised: #+BEGIN_SRC javascript // import ASP import { JLI } from './jli.js';

// import LISP Commands import { LISP_COMMANDS as LISP } from './lisp.js';

// initialise JLI with LISP commands const jli = JLI({COMMANDS: LISP}); #+END_SRC

** Initialisation JLI can be initialised by calling the JLI function. You are free to provide a custom Command Set and custom defaults, depending on your use case. #+BEGIN_SRC javascript // COMMANDS and DEFAULT are optional const jli = JLI({COMMANDS, DEFAULTS}); #+END_SRC All the following tutorials asume you have JLI initialised as jli* and imported the lisp library

* Configuration ** COMMANDS JLI_COMMANDS is an object in which every key represents a function name and every value is a function. Those functions are called with multiple Arguments, although the firts one is always the TOOLS object. The TOOLS Object bridges all the default values to the function (e.g. TOOLS.print) #+BEGIN_SRC javascript COMMANDS = { // basic command syntax command:(TOOLS, ...values)=> { }, // example printing to the console print: ({print}, msg) => print(msg) } #+END_SRC ** DEFAULTS JLI_DEFAULTS is an object containing key - value pairs with the key and a function assigned. See below for more information on the default setup. #+BEGIN_SRC javascript const DEFAULTS = { output: console.log, input: (msg)=>{ console.log(msg); return "demo input"; }, error: (err) => { throw new Error(err); } }; #+END_SRC ** BLACKLIST JLI_BLACKLIST provides a way to disable automatic resolution of all part of the command. This can be done manually by the command using TOOLS.resolve(); The blacklist is an Array of command names. **** STATE JLI_STATE provides the global objects used to create variables and functions. It might be provided manally given that you want to overwrite it from vanilla javascript.

* Types of Executives ** JLI (array) (default) The default way of using ASP is by following the javascript way of declaring arrays. Those Arrays represent Lisp list, but are also used as Scheme brackets around commands. For running default ASP code you may use asp.run(code); #+BEGIN_SRC javascript // run default ASP code asp.run(/Array/ code);

// example asp.run("print" 5); // prints 5 in the console #+END_SRC ** JLI (string) You can also store your ASP code inside a string before execution. To execute ASP code from a string do #+BEGIN_SRC javascript asp.exec('"print", "hello world!"'); // prints "hello world!" #+END_SRC ** lispy JLI (string) Lispy ASP is a lisp like flavour of ASP, you don't use square brackets here, only the rounded type. The way of executing Lispy ASP stored inside a string is similar to the regular ASP inside a string, although you have to pass a true to the exec function. This will tell the exec function to replace all rounded brackets with squeare onces upon execution. #+BEGIN_SRC javascript asp.exec('("print", "hello")', true); // prints "hello" #+END_SRC **** true JLI (string) As with lispy ASP, the Lispy flavour has to stored inside a string, as vanilla JS doesn't allow for rounded brackets. Lispy uses the same technique as lispy ASP but it inserts the comma seperation the items automatically. ATTENTION: You still have to insert the quotes around commands and strings. #+BEGIN_SRC javascript asp.runLisp('("print" ("+" 1 2))'); // prints "3" #+END_SRC

* JLI() ** .run(array) ** resolve(array) ** exec(string, boolean?) ** lispToJLI(string) ** runLisp(string) LISP Library Examples See demo.js for a growing selection of examples (might be commented out) Problems Use cases

  • custom chat bots
  • custom scheme based languages
  • lispy feeling
  • TurtleOS
1.0.0

3 years ago