/*****
* process.h
* Andy Hammerlindl 2006/08/19
*
* Handles processing blocks of code (including files, strings, and the
* interactive prompt, for listing and parse-only modes as well as actually
* running it.
*****/
// Process the code respecting the parseonly and listvariables flags of
// settings.
void processCode(absyntax::block *code);
void processFile(const string& filename, bool purge=false);
void processPrompt();
// Run the code in its own environment.
void runCode(absyntax::block *code);
void runString(const string& s, bool interactiveWrite=false);
void runFile(const string& filename);
void runPrompt();
// Run the code in a given run-time environment.
typedef vm::interactiveStack istack;
void runCodeEmbedded(absyntax::block *code, trans::coenv &e, istack &s);
void runStringEmbedded(const string& str, trans::coenv &e, istack &s);
void runPromptEmbedded(trans::coenv &e, istack &s);
// Abstract base class for the core object being run in line-at-a-time mode, it
// may be a block of code, file, or interactive prompt.
struct icore {
virtual ~icore() {}
virtual void doParse() = 0;
virtual void doList() = 0;
// Abstract base class for one-time processing of an abstract syntax tree.
class itree : public icore {
string name;
absyntax::block *cachedTree;
public:
itree(string name="<unnamed>");
virtual absyntax::block *buildTree() = 0;
// Build the tree, possibly throwing a handled_error if it cannot be built.
virtual absyntax::block *getTree();
virtual string getName();