dimkr / szl Goto Github PK
View Code? Open in Web Editor NEWA lightweight, embeddable scripting language
Home Page: http://dimakrasner.com/szl
License: MIT License
A lightweight, embeddable scripting language
Home Page: http://dimakrasner.com/szl
License: MIT License
_ ___ ___| | / __|_ / | \__ \/ /| | |___/___|_| Overview ======== szl is a tiny, embeddable scripting engine inspired by Tcl and shell. It's a balanced mix of their key features: szl combines the simplicity of shell scripting with the power of a dynamic, Tcl-like type system, minimalistic syntax and programming language features missing in the shell, like exceptions and OOP. szl comes with a rich standard library that includes bindings for permissively-licensed libraries. Therefore, it can run processes, parse text with transparent Unicode support, manipulate data structures like dictionaries, operate on binary data, interface with C code through scripts, multiplex non-blocking I/O at scale, call REST APIs and much more, at a fraction of the memory and size footprint of other scripting languages, while achieving reasonable efficiency. szl can be used both as a standalone (either interactive or non-interactive) interpreter or as an integral part of other projects, via the libszl library. In addition, the feature set and behavior of szl can be easily fine-tuned to meet the size and memory consumption limitations under various usage scenarios and hardware platforms. ___________________________________ / \ | >>> $global msg {Hello, world!} | | Hello, world! | | >>> $load zlib | | >>> $zlib.crc32 $msg | | 3957769958 | | >>> [$exec {uname -s}] read | | Linux | | >>> [$open /bin/gunzip rb] read 9 | | #!/bin/sh | | >>> $map i [$range 1 4] {$+ $i 3} | | 4 5 6 | \___________________________________/ For more information, see the user manual at http://dimakrasner.com/szl. Building ======== On Debian (http://www.debian.org) based distributions: $ apt-get install git gcc meson zlib1g-dev libcurl4-gnutls-dev libarchive-dev libssl-dev libffi-dev Then: $ git clone --recursive https://github.com/dimkr/szl $ cd szl $ meson build $ cd build $ ninja $ ninja install By default, szl is built with core functionality built-in to the interpreter, while a big part of the standard library resides in dynamically-loaded shared objects. This way, the memory consumption of szl scripts that don't use the entire standard library is lower. However, in some use cases (for example, when szl is embedded into another project), this is undesirable. To build szl as a single executable file, with all extensions linked statically into the interpreter: $ mesonconf -Dbuiltin_all=true In addition, built-in extensions can be chosen individually, e.g.: $ mesonconf -Dwith_curl=builtin -Dwith_ffi=no Embedding ========= To embed szl into other projects, use the API defined in szl.h and link with libszl. The size and performance of szl can be tuned using advanced build options: $ mesonconf -Duse_int=true This build option replaces the large integer type used by szl to represent integers, to the standard C int. This may improve performance under platforms without native support for 64 bit integers, at the cost of a limited range of valid integer values. $ mesonconf -Duse_float=false This build option changes the precision of floating-point numbers in szl from double to single precision. This may improve performance under platforms without native support for double-precision floating point numbers, at the cost of precision. $ mesonconf -Dwith_float=false This build options disables support for floating-point arithmetic. This reduces szl's size. $ mesonconf -Dwith_unicode=false This build options disables support for Unicode strings and cancels szl's internal distinction between encoded byte strings and arrays of Unicode code points. This reduces szl's size and may improve performance with zero side effects, if szl is guaranteed not to perform any sort of Unicode string slicing. Security ======== Support for dynamic loading of szl extensions can be disabled: $ mesonconf -Dwith_dl=false When dynamic loading is disabled, szl will refuse to load extensions, unless they are linked statically into the interpreter. This way, a szl interpreter embedded into another program does not make it vulnerable to dynamic loader hijacking (e.g. LD_LIBRARY_PATH) during extension loading. Running ======= To run an interactive interpreter: $ szlsh Or, to run a script: $ szl $path Or, to run a one-liner: $ szl -c $snippet Credits and Legal Information ============================= szl is free and unencumbered software released under the terms of the MIT license; see COPYING for the license text. For a list of its authors and contributors, see AUTHORS. The ASCII art logo at the top was made using FIGlet (http://www.figlet.org/).
Attempting a build on macOS Sierra, but I get this after running make
:
szl_builtin.c:27:2: error: use of undeclared identifier 'n'
-n "obj",
^
after cloning the repo recursively, trying to build with cmake:
$ mkdir build
$ cd build
$ cmake ..
got this after make
:
[ 1%] Minifying szl
[ 2%] Generating szl_builtin.c
[ 3%] Minifying dir
[ 5%] Minifying io
Scanning dependencies of target libszl
[ 6%] Building C object src/CMakeFiles/libszl.dir/libszl.c.o
[ 7%] Building C object src/CMakeFiles/libszl.dir/szl_builtin.c.o
/home/stealth/szl/build/src/szl_builtin.c:2:17: fatal error: szl.h: No such file or directory
compilation terminated.
src/CMakeFiles/libszl.dir/build.make:97: recipe for target 'src/CMakeFiles/libszl.dir/szl_builtin.c.o' failed
make[2]: *** [src/CMakeFiles/libszl.dir/szl_builtin.c.o] Error 1
CMakeFiles/Makefile2:101: recipe for target 'src/CMakeFiles/libszl.dir/all' failed
make[1]: *** [src/CMakeFiles/libszl.dir/all] Error 2
Makefile:117: recipe for target 'all' failed
make: *** [all] Error 2
this is what helps to continue:
ln -s ../../src/szl.h src/szl.h
but then it fails on doxygen (since I have it installed):
…
[ 97%] Built target szl_zstd
Scanning dependencies of target api_doc_gen
[ 98%] Generating API documentation
error: configuration file doxygen.conf not found!
Doxygen version 1.8.9.1
Copyright Dimitri van Heesch 1997-2014
You can use doxygen in a number of ways:
1) Use doxygen to generate a template configuration file:
doxygen [-s] -g [configName]
If - is used for configName doxygen will write to standard output.
2) Use doxygen to update an old configuration file:
doxygen [-s] -u [configName]
3) Use doxygen to generate documentation using an existing configuration file:
doxygen [configName]
If - is used for configName doxygen will read from standard input.
4) Use doxygen to generate a template file controlling the layout of the
generated documentation:
doxygen -l [layoutFileName.xml]
5) Use doxygen to generate a template style sheet file for RTF, HTML or Latex.
RTF: doxygen -w rtf styleSheetFile
HTML: doxygen -w html headerFile footerFile styleSheetFile [configFile]
LaTeX: doxygen -w latex headerFile footerFile styleSheetFile [configFile]
6) Use doxygen to generate a rtf extensions file
RTF: doxygen -e rtf extensionsFile
If -s is specified the comments of the configuration items in the config file will be omitted.
If configName is omitted `Doxyfile' will be used as a default.
-v print version string
doc/CMakeFiles/api_doc_gen.dir/build.make:49: recipe for target 'doc/CMakeFiles/api_doc_gen' failed
make[2]: *** [doc/CMakeFiles/api_doc_gen] Error 1
CMakeFiles/Makefile2:644: recipe for target 'doc/CMakeFiles/api_doc_gen.dir/all' failed
make[1]: *** [doc/CMakeFiles/api_doc_gen.dir/all] Error 2
Makefile:117: recipe for target 'all' failed
make: *** [all] Error 2
I also think documentation generation should be optional.
Greetings,
I've been trying to compile szl under OpenBSD, and I got a compiler error, for some missing stuff (I don't remember what exactly) in the src/szl_exec.c file, so I figured out that it's signal.h is missing, and I included it, here is a patch:
diff --git a/src/szl_exec.c b/src/szl_exec.c
index 9b31806..7bc1ae7 100644
--- a/src/szl_exec.c
+++ b/src/szl_exec.c
@@ -22,6 +22,7 @@
* THE SOFTWARE.
*/
+#include <signal.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
However, I kept getting issues about implicit declarations in other files 'szl_poll.c' and the issue is, sys/epoll.h is a linux header, and it's not portable, so including such a thing will harm portability and prevent me from running szl on openbsd, are you aware of that?
After: sudo apt-get install git gcc meson zlib1g-dev libcurl4-gnutls-dev libarchive-dev libssl-dev libffi-dev
After: git clone --recursive https://github.com/dimkr/szl
After: cd szl
:~/szl$ meson build
Error during basic setup:
[Errno 2] No such file or directory: '/home/jake/szl/build'
jake@rexcore2:/szl$ mkdir build/szl$ meson build
jake@rexcore2:
The Meson build system
Version: 0.29.0
Source dir: /home/jake/szl
Build dir: /home/jake/szl/build
Build type: native build
Build machine cpu family: x86_64
Build machine cpu: x86_64
Project name: szl
Native c compiler: cc (gcc 5.4.0-6ubuntu1)
Meson encountered an error in file src/meson.build, line 23, column 0:
Unknown function "join_paths".
=====
I am unfamiliar with meson. Can you see anything I'm doing wrong?
some doubts:
1- supports 16, 32 and 64-bit compilers?
2- support anothers c compilers, like microsoft c++, tcc, bcc or armcc ?
3- is endianess safe (little and big-endian cpus) ?
4- curated projects ?
thanks!
szl is the runtime environment of Google's sawzall written by Rob Pike and others.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.