From a5f00256b0205e9ac6c8a5a53d5ff492adbedc5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Janouch?= Date: Sat, 6 May 2017 14:12:46 +0200 Subject: Make this look like a project --- .gitignore | 9 ++++++ LICENSE | 13 +++++++++ README.adoc | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ell.c | 19 +++++++++++++ 4 files changed, 136 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.adoc diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4fdc357 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +# Build files +/build + +# Qt Creator files +/CMakeLists.txt.user* +/ell.config +/ell.files +/ell.creator* +/ell.includes diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c949ca2 --- /dev/null +++ b/LICENSE @@ -0,0 +1,13 @@ +Copyright (c) 2017, Přemysl Janouch + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/README.adoc b/README.adoc new file mode 100644 index 0000000..6206715 --- /dev/null +++ b/README.adoc @@ -0,0 +1,95 @@ +ell +=== +:compact-option: + +'ell' is a modified subset of Scheme with added syntax sugar, incorporating +ideas from Perl, Tcl and Bourne shell. The goal was to conceive a programming +language implementable with as little code as possible while still being +reasonably comfortable to use. + +This package is an implementation of said language, meant to be self-contained, +portable and reusable. Performance is specifically not an intent. + +Syntax +------ +Owing to its Scheme heritage, 'ell' is homoiconic, that is a program can be +directly expressed using the language's data types. There are only two of +those: the list and the string. Any numerical conversions are made on an +as-needed basis. Similarly, strings act like atoms/symbols when executed. + +The parser, however, does a bunch of transformations: + + * `[a b c]` makes a call to `(list a b c)`; + * `@var` is a shorthand for `(set var)`; + * `{ code }` is the most complex one. Each line within the curly braces is + wrapped in parentheses, and the resulting list is quoted, so that it doesn't + execute immediately. + +As an example, consider the following snippet: + + print (if { = @var foo } { + quote 'Hello world\n' + } else { + quote 'Error\n' + }) + +which gets expanded to the following: + + ((print (if (quote ((= (set var) foo))) + (quote ((quote 'Hello world\n'))) + else + (quote ((quote 'Error\n')))))) + +Observe that the whole program is enclosed in an implicit pair of `{}` and that +`quote` is a very powerful special form which can replace many others if needed. + +Runtime +------- +All variables are put in a single global namespace with no further scoping. +When calling a command (which is a list of lists), all arguments are +automatically stored in variables named 1, 2, 3, ... n. They are however +effectively inaccessible and you must rename them first using the `arg` special +form. + +When evaluating a command, the first argument is typically a string with its +name and it is resolved as if `set` was called on it. + +The last expression in a block is the return value. + +Special forms +------------- +`quote ` + +Returns the first argument. + +`arg ...` + +Reassigns arguments to the current call in order to given names. This must be a +special form because of the lack of variable scoping. It needs to see arguments +from the other scope. + +Standard library +---------------- +`if [elif ]... [else ]` + +Conditional evaluation, strings evaluate to themselves. + +`funargs` + +Returns arguments to the current evaluation context as a list. + +Contributing and Support +------------------------ +Use this project's GitHub to report any bugs, request features, or submit pull +requests. If you want to discuss this project, or maybe just hang out with +the developer, feel free to join me at irc://irc.janouch.name, channel #dev. + +License +------- +'ell' is written by Přemysl Janouch . + +You may use the software under the terms of the ISC license, the text of which +is included within the package, or, at your option, you may relicense the work +under the MIT or the Modified BSD License, as listed at the following site: + +http://www.gnu.org/licenses/license-list.html diff --git a/ell.c b/ell.c index b0228fa..9d786e4 100755 --- a/ell.c +++ b/ell.c @@ -1,3 +1,22 @@ +/* + * ell.c: an experimental little language + * + * Copyright (c) 2017, Přemysl Janouch + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ + #define _XOPEN_SOURCE 500 #include -- cgit v1.2.3