description | Funky embeddable interpreter and programming language |
homepage URL | http://funky.sourceforge.net/ |
owner | ronald@landheer-cieslak.com |
last change | Mon, 12 Jan 2009 18:16:18 +0000 (12 13:16 -0500) |
URL | git://repo.or.cz/Funky.git |
https://repo.or.cz/Funky.git | |
push URL | ssh://repo.or.cz/Funky.git |
https://repo.or.cz/Funky.git (learn more) | |
bundle info | Funky.git downloadable bundles |
content tags |
As the documentation will tell you, Funky is a tiny, easily embeddable functional programming language, written in C++. As the language and the interpreter are both pretty small, there is nothing much to tell about them, except perhaps the "when", "why", "what" and "how" of its history, so here goes..
The very first version of Funky was created during my daughter's nap on a snowy sunday afternoon. It was slightly refined one evening while my daughter and my wife were both sleeping and I was rocking the baby's "cozy" with my foot (as I am doing now). The initial programming therefore took about 90 minutes, whereas a bit of fine-tuning and turning the original parser/interpreter into a parser/interpreter with two phases (parsing and interpreting) took another two hours or so.
The original idea wasn't mine: at work, a colleague needed a functional, embeddable programming language and created one from scratch. It took him a few days to do so, but he wrote the parser and the scanner by hand. I heard about his little language and thought it might be a nice idea to have one of those in the free world.
Also, as a personal challenge, I decided I should be able to write one of those in much less time that a few days, but using the right tools. Hence, one sunday afternoon I took my laptop computer and started typing. I decided to use Boost.Spirit to write the parser: I had already read the documentation once while doing some research for the Jail programming language and found it a pretty good framework to build a parser one. 90 minutes later, I had the first working version of a Funky interpreter (but it wasn't embeddable yet and didn't split the parsing and interpreting phases).
As stated, Funky is a tiny, embeddable programming language with almost unlimited extending capabilities. It presents itself as a single class which contains the entire interpreter. Two versions of this class exist: Funky::Funky, which is a floating-point version, and Funky::Groovy, which is an integer version. You can install your own functions in the language as long as your functions take a vector of the built-in type of the interpreter as return an instance of that built-in type (or a vector of those).
Funky is a functional programming language. As such, it treats everything as functions and those functions handle only one type: double in the case of Funky::Funky or int in the case of Funky::Groovy.
The documentation provided on this site is far more exhaustive than I care to be on this page, so for more details I'll refer you there..
The current version of Funky works in two phases: it first creates an abstract syntax tree by parsing the input you pass to it. It then prunes the tree of anything that is can see as a function, and stores those functions in an internal map, with the function pointers you may already have given it. As every function can only have one definition, the script's definitions of any functions you may have put in the interpreter will override anything you have given it at that point - but you can install functions after the parsing phase.
Once it starts evaluating the parsed script, it creates an evaluator and passes the parsed "main" function to it - the main function is the function without an explicit name that comes at the end of the script. The evaluator traverses the AST, calls any functions that need calling and will finally return with a value, which will be the return value of the script.
Hence, running a script goes through two distinct phases: parsing and evaluating, which allows you to determine which functions can be overridden by user scripts (the ones you install before parsing) and which can't (the ones you install after parsing).
For your convenience, the source distribution contains a "solution" file for Microsoft Visual Studio 2005 as well as a GNU autoconf-generated configury. The GNU "project" files do not use GNU automake, but do use GNU libtool and have been tested on Debian GNU/Linux Stable and on Cygwinhttp://cygwin.com
In order to compile Funky, you need to have a version of Boost that includes Boost.Spirit installed somewhere where your compiler can find it. You also need Loki by Andrei Alexandrescu for its ScopeGuard.
As far as I know, I cannot legaly distribute the DLL compiled with Visual Studio so, for the time being, you will have to compile it yourself. If there is any demand for it, I will create a C API for Funky and distribute a DLL compiled with MinGW.
Should there be any demand for them, I'll be happy to create Debian and/or Cygwin packaged of Funky as well.
15 years ago | master | logtree |