vx (Varyx Executor)
https://www.vcode.org/vx/
vx
is an interpreter for the Varyx programming language.
The vx
source code is AGPL-licensed and published on GitHub.
Synopsis
vx OPTIONS hello-world.vx
vx OPTIONS -e 'print "Hello world"'
In the first form, vx
will attempt to open the file given as the first argument (hello-world.vx
) and execute its contents as Varyx code.
In the second form, vx
will execute the parameter to the -e
option (print "Hello world"
) as Varyx code.
In either form, any subsequent arguments will be stored in argv
.
The -Z
option indicates "zero restrictions", and should only be specified for programs that the user trusts not to cause harm.
Extensions
These facilities are not part of Varyx proper because they interact with the host environment.
argv
is an array of strings, consisting of either the program pathname or"-e"
, followed by the remaining arguments (following either the program pathname or inline source, respectively).eval(string) => ...
is a sandboxed eval() function. It parses the string as Varyx code and executes it. Only the keyword symbol table is visible — everything else, including impure functions, all local and global program state, and eval() itself, are unavailable to the sandboxed code. If a parsing error, run-time error, or uncaught exception occurs, an exception is thrown. Otherwise, the result of executing the parsed code is returned.getenv(string) => string|()
works like its C counterpart, returning the value of the named environment variable. If the variable is not set in the environment, it returns()
, the empty list.load(string) => string
reads the contents of the regular file whose pathname is passed and returns them, or throws an exception on error.print(...)
accepts any list of printable values (including the empty list), concatenates them, appends'\n'
, and writes the result to standard output.system(string|()) => int
is a wrapper around C’ssystem()
. If the-Z
option wasn’t specified, it can only be called with an empty argument list, and it returns an empty list. If the-Z
option was specified, then given an empty list it returnstrue
if the system shell facility is available orfalse
if it isn’t. Given a string with no NUL bytes (and the-Z
option), it runs the string as a shell command. If the nativesystem()
call returns an error, or the shell’s status indicates that it terminated on a signal or exited with a non-zero status, then an exception is thrown. Otherwise, zero is returned.time() => int
works like its C counterpart, returning the number of seconds since 1970-01-01.