Emoji Lisp

(Friday)
It all started with the fact that I read in Stanislaw LEM's novel "Peace on Earth" (1985) that in the future communicating in the language will be replaced with communication by means of pictograms. I thought it was quite prophetic in connection with increasing interest to a variety of emoticons and other types of larger images and I thought: what if programming with the help of emoji? Searching online I was convinced that this idea already came up in the heads of the people and embodied in the draft https://github.com/wheresaddie/Emojinal
but this project has not impressed me in the first language does not have the completeness and the General approach of the author as an attempt to replace the part of operators with the help of emoji seem not very interesting.

I thought that Lisp would be much better to lie down on the emoji, because the closing-opening bracket is already like the smilies, plus, the language itself is very simple, the compiler can write fairly quickly and to ensure that all "worked" does not require the implementation of a large number of different structures.

Because I wanted to give users the ability to easily try out this new language, it was decided to make it embedded in the browser. As the language compiler could choose any language that compiles to JavaScript, but I chose just JavaScript and decided to write so that it could compile in the environment node.js and in the browser. The second point I would like to achieve is the variability of a set of emoji, I have since the first operations began to doubt that the choice of emoji presentation is really clear and decided to do everything so that another developer was to simply replace this set of characters, and see what we get new emoji. For this reason, all the examples of tests are written as templates, which are populated with the current set.

As a language to describe the grammar I've chosen PEG, the only problem with it was that unicode characters could not make the transfer under the conditions (had to be separately through the first and second symbol, because it is a few characters). Plus had a problem related to the recompilation PEG-parser, as he had each time to change the definition of identifiers (wykonywa brackets) and regenerate the parser using PEG.js that seemed to me quite slow on the browser side. Was made quite a simple solution — before submitting the program for lexical analysis to replace the current symbols from a set of brackets for normal brackets, and then parse with the usual brackets. Turned a PEG:
the
start
= s:sexpr* {return {type:"Program", body:s}}

leftBracket
= "("

rightBracket
= ")"

identifier
= [\uD83D][\uDC36-\uDE4F]
/ [\uD83D][\uDE80-\uDEC5]
/ [\uFE0F]
/ [\u2702-\u27B0]
/ [\u24C2]
/ [\uD83C][\uDC04-\uDFE2]
/ [\u20E3-\u3299]

number
= [0-9]+

_ "whitespace"
= [\t\v\f \n\u00A0\uFEFF]*

sexpr
= a:atom { return a; }
/ list

list
= leftBracket _ head:sexpr
tail:(_ sexpr)* _ rightBracket _ {
var result = [head];
for (var i = 0; i < tail.length; i++) {
result.push(tail[i][1]);
}
return {type: 'List', contents:result};
}

atom
= d number _ { return {type: 'Literal', value: parseInt(d.join(""), 10)}}
/ '"' d:(!'"' [a-z])* '"' _ { return {type: 'Literal', value: d }}
/ s:identifier _ { return {type: 'Identifier', name: s.join?s.join(""):s}}


Next-easier: I chose a set of features that were included in a simple standard library is:

and to demonstrate their work written calculation of the Fibonacci numbers, the calculation itself and a few simple programs
in addition, expertravel images and codes from the project gemoji for a more visual demonstration.

It looks like a program that evaluates to itself:

here months — brackets, animals — IDs, and the rest of the structure is above.

It looks like the program for Fibonacci numbers:

this is a recursive function whose name — dog. Emoji characters you can write in a row, but the numbers are consecutive, you need to separate them with spaces if they are different numbers.
In the first version is months used sad-funny emoticons, but because of their similarity code was much more complicated to structure, for this reason went on for months. However, I do not understand why in the standard set of emoji there are months, looking in different directions.

In the process found out that emoji are not so well supported, for example, the sublime allows you to copy only some of them, if you try to copy the text program evaluates to itself, in the clipboard will be empty. From desktop browsers is more or less normal emoji supported Safari. Compiler supports emoji in unicode characters and there's even a repl but write terminal is also not too good supports such symbols, they come to each other, but I hope that in the future the situation will improve and we can safely write calls Emoji tools directly at the command line.

All source code available on https://github.com/parsifal-47/emojilisp, it is possible to extend the standard library or write a request, you can also try their hand at programming in this simple set of features at emojilisp.com. And as I wrote in the beginning, I wanted to be able to override the emoji set of appropriate functions without much difficulty. This can be done by changing files in the conf folder of the project on github or by clicking on "create your own set" on the website, and then Seth, like any program, you can share it. Here, for example, a variant with a more interesting symbol for this operation list.

In addition, there is difficult to check the idea that such a language might be easier understood by children and perhaps some that will be programming the future.
Article based on information from habrahabr.ru

Комментарии

Популярные сообщения из этого блога

Monitoring PostgreSQL + php-fpm + nginx + disk using Zabbix

Templates ESKD and GOST 7.32 for Lyx 1.6.x

Customize your Google