Translator from lisp to JS (just for fun, or not?)
This app is implemented in Node, so you need to install Node.js(preferably the latest version) and npm on your machine.
git clone [email protected]:Guseyn/lispToJS.git
cd lispToJS
npm install
npm run start
You can open it on http://localhost:8000/
npm test
Left editor is for typing in lisp. Right area is for JS code. JS area displays updates from backend as you type lisp code. But it does not update hightlighing of lisp code(because it slows down app), and you have to click somewhere outside of lisp editor to update highlighting of lisp code.
lisp
(x (y (z) (a)))
js
[x, [y, [z],
[a]
]]
lisp
(+ a (- b (* c (/ d e))) (+ f g) )
js
(a + (b - (c * (d / e))) + (f + g))
lisp
(let ((var1 val1) (var2 val2)) ())
js
let var1 = val1
let var2 = val2
lisp
(defun name (v1 v2) (+ v1 v2))
js
function sum(v1, v2) {
return (v1 + v2)
}
lisp
(defun sum (v1 v2) (+ v1 v2))(sum (10, 10))
js
function sum(v1, v2) {
return (v1 + v2)
}
sum(10, 10)
Only format
function is supported by default. So, if you want to the system detect your functions you must declare them first.
lisp
(loop for x in ("tom" "dick" "nina") do (format (t "~s" x)))
js
for (let x in ['tom', 'dick', 'nina']) {
format(t, '~s', x)
}
lisp
(if (< a 20) (format (t "~% a is less than 20")) (format(t "~% a is more than 20")))
js
if ((a < 20)) {
return format(t, '~% a is less than 20')
}
return format(t, '~% a is more than 20')
lisp
(lambda (x y) (+ x 10))
js
(x, y) => {
return (x + 10)
}
lisp
(defun max (v1 v2)
(if (> v1 v2) v1 v2))
js
function max(v1, v2) {
if ((v1 > v2)) {
return v1
}
return v2
}
Request
POST
request with plain text body like (defun max (v1 v2) (if (> v1 v2) v1 v2))
Possible Responses
{
"isValid": true
}
{
"isValid": false
}
Request
POST
request with plain text body like (defun max (v1 v2) (if (> v1 v2) v1 v2))
Possible Responses
{
"js": "function max(v1, v2) {\n if ((v1 > v2)) {\n return v1\n }\n return v2\n}"
}
{
"js": "Not Valid Lisp"
}