Falcon::InteractiveCompiler Class Reference

Interactive compiler. More...

#include <intcomp.h>

Inheritance diagram for Falcon::InteractiveCompiler:

Inheritance graph
[legend]

List of all members.

Public Types


Public Member Functions

virtual void addLoad (const String &name, bool isFilename)
 Adds a direct load request to the module being compiled.
virtual void addNamespace (const String &nspace, const String &alias, bool full=false, bool filename=false)
 Adds a known namespace.
t_ret_type compileAll (const String &input)
t_ret_type compileNext (const String &input)
 Compile another codeslice from a string.
t_ret_type compileNext (Stream *input)
 Compile another code slice coming from the stream.
void interactive (bool iactive)
 Sets or resets interactive mode.
bool interactive () const
 InteractiveCompiler (ModuleLoader *loader, VMachine *vm)
 Create the interactive compiler.
void loader (ModuleLoader *l)
ModuleLoaderloader () const
VMachinevm () const
 ~InteractiveCompiler ()


Detailed Description

Interactive compiler.

This compiler is meant to incrementally compile, load dependencies and execute on the fly single statements.

For this reason, the compiler is provided with a VM and a flexy module; the compiler independently creates the module (which may be referenced and taken also externally) and exposes a function that allows incremental compilation. Using compileNext(), this class independently loads dependencies as they are found, executes statements and fills the module symbol table.

The compiler may be provided with a VM generated from the outside, or it will create a standard VM on its own (which can be configured at a later moment.


Member Enumeration Documentation

Enumerator:
e_nothing  Do-nothing statements (comments, whitespaces .

..)

e_more  We need more to finish the current statement.
e_incomplete  Incomplete context.
e_decl  Statement was a complete declaration (function, object, class.

..)

e_statement  Normal statement (assignment, if block, while block.

..)

e_expression  Stand alone expression (sum, sub, single value).
e_call  Special expression consisting of a single call to a sub expression.

Usually, the user expects a return value.

e_terminated 


Constructor & Destructor Documentation

Falcon::InteractiveCompiler::InteractiveCompiler ( ModuleLoader loader,
VMachine vm 
)

Create the interactive compiler.

If a VM is not provided, it will be automatically created. Notice that the compiler will apply its error handler to the loader at compile time.

Falcon::InteractiveCompiler::~InteractiveCompiler (  ) 


Member Function Documentation

virtual void Falcon::InteractiveCompiler::addLoad ( const String name,
bool  isFilename 
) [virtual]

Adds a direct load request to the module being compiled.

Parameters:
name The name of the module to be loaded
isFilename True if the name to be loaded is actually a filename path.

Reimplemented from Falcon::Compiler.

virtual void Falcon::InteractiveCompiler::addNamespace ( const String nspace,
const String alias,
bool  full = false,
bool  filename = false 
) [virtual]

Adds a known namespace.

Parameters:
nspace The namespace to be added (as module name).
alias If not empty, will be the alias under which the module will be locally known.
full If true, import all symbols.
filename If true, the load request was for a direct filename.

Reimplemented from Falcon::Compiler.

t_ret_type Falcon::InteractiveCompiler::compileAll ( const String input  ) 

t_ret_type Falcon::InteractiveCompiler::compileNext ( const String input  ) 

Compile another codeslice from a string.

See also:
compileNext( Stream *);

t_ret_type Falcon::InteractiveCompiler::compileNext ( Stream input  ) 

Compile another code slice coming from the stream.

The calling application will receive the control back when the compilation, and eventually the execution of the needed steps are completed.

The return value may be one of the t_ret_type enumeration, and the calling application can take proper actions.

A return indicating error won't block the compiler nor invalidate, which is still available to compile incrementally other code slices.

void Falcon::InteractiveCompiler::interactive ( bool  iactive  )  [inline]

Sets or resets interactive mode.

In interactive mode, the compiler accepts one statement at a time and transforms expressions into "return [expression]" statements to allow their value to be visible after the execution.

Also, the lexer is configured so that it can accept partial elements from streams and tell back about a partial status to the compiler.

bool Falcon::InteractiveCompiler::interactive (  )  const [inline]

void Falcon::InteractiveCompiler::loader ( ModuleLoader l  )  [inline]

ModuleLoader* Falcon::InteractiveCompiler::loader (  )  const [inline]

VMachine* Falcon::InteractiveCompiler::vm (  )  const [inline]


The documentation for this class was generated from the following file:

Generated on Mon Oct 19 10:11:36 2009 for Falcon_Core by  doxygen 1.5.8