jplus-0.4.7
|
A J+ script. More...
#include <src/jplus.h>
Public Member Functions | |
jplus () | |
initialize J+ engine with no script | |
bool | init (std::istream &script) |
Load and pre-parse J+ script. | |
~jplus () | |
Free allocated memory. | |
bool | set (std::string name, jarray data) |
Set value of the specified variable inside J+ environment, mark all dependent variables "dirty". | |
jarray | get (std::string name) |
Perform all the necessary calculations to computate the specified variable, return its value in an array. | |
std::vector< std::string > | getProgram (std::set< std::string > vars) |
Pull minimal set of J sentences for computing a given set of variables, assuming everything is "dirty". | |
std::vector< std::string > | getProgram () |
Pull all the sentences in J+ script. | |
Public Member Functions inherited from jengine | |
jengine () | |
Initializes J engine. | |
~jengine () | |
Frees J engine memory. | |
bool | doJ (const std::string s) |
Executes J sentence. | |
const jarray | get (const std::string name) |
Retrieves a named array from J. | |
bool | set (const std::string name, jarray &value) |
Assigns J name to the specified array. | |
int | getError () |
J error code for the last unsuccessful operation. | |
bool | ok () |
Conveniently check that there was no error. | |
bool | defVerb (std::string name, monad mf, dyad df, int mr=RMAX, int lr=RMAX, int rr=RMAX) |
Defines J verb, calling one (or both) of specified C++ functions. | |
bool | defAdverb (std::string name, amonad mf, adyad df) |
defines J adverb, calling one (or both) of specified C++ functions. | |
bool | defScript (std::string name, int type, std::string code, int mr=jengine::RMAX, int lr=jengine::RMAX, int rr=jengine::RMAX) |
Defines a J script, given by a (possibly multi-line) string. | |
bool | isBuiltin (std::string name) const |
Checks if given name was defined via defScript. | |
std::set< std::string > | getBuiltins () const |
Returns set of all names defined via defScript. | |
jarray::I | PROLOG () |
Returns the top of J garbage collection stack. | |
jarray::I | EPILOG (jarray::I oldtop) |
Frees all memory, allocated since ttop was recorded. | |
void * | EPILOG (jarray::I oldtop, void *hdr) |
Frees all memory, allocated since ttop was recorded. | |
Protected Member Functions | |
virtual void | libInit () |
Called by the constructor before parsing the J+ script. | |
Protected Member Functions inherited from jengine | |
void * | GA (const jarray::I t, const jarray::I n, const jarray::I r, const jarray::I *s) |
Allocates J array. | |
void | FR (void *hdr) |
Frees J array memory. | |
Additional Inherited Members | |
Public Types inherited from jengine | |
typedef jarray(* | monad) (jarray y) |
Pointer to function, implementing monadic variant of a verb. | |
typedef jarray(* | dyad) (jarray x, jarray y) |
Pointer to function, implementing dyadic variant of a verb. | |
typedef jarray(* | amonad) (monad um, dyad ud, jarray y) |
Pointer to function, implementing monadic variant of an adverb. | |
typedef jarray(* | adyad) (monad um, dyad ud, jarray x, jarray y) |
Pointer to function, implementing dyadic variant of an adverb. | |
Static Public Member Functions inherited from jengine | |
static void | initJlibrary (std::ostream &) |
Loads and links J dynamic library, must be called once before this class is instantiated. | |
Static Public Attributes inherited from jengine | |
static const int | RMAX =10000 |
Constant to denote the infinite rank. | |
A J+ script.
jplus::jplus | ( | ) |
initialize J+ engine with no script
jplus::~jplus | ( | ) |
Free allocated memory.
jarray jplus::get | ( | std::string | name | ) |
Perform all the necessary calculations to computate the specified variable, return its value in an array.
name | name of variable to compute. |
std::vector< std::string > jplus::getProgram | ( | ) |
Pull all the sentences in J+ script.
This pulls all the sentences, assigning value of some variable.
std::vector< std::string > jplus::getProgram | ( | std::set< std::string > | vars | ) |
Pull minimal set of J sentences for computing a given set of variables, assuming everything is "dirty".
vars | set of variable names to pull. |
bool jplus::init | ( | std::istream & | script | ) |
Load and pre-parse J+ script.
script | stream, containing the script to load. |
Called by the constructor before parsing the J+ script.
Does nothing by default, but can be overridden to prepend an additional J+ stream with some definitions and/or define a few verbs and adverbs to be used in J+ program.
Reimplemented in yacts.
bool jplus::set | ( | std::string | name, |
jarray | data | ||
) |
Set value of the specified variable inside J+ environment, mark all dependent variables "dirty".
name | name of the variable. |
data | array for the variable to refer to. |