Script Program. More...

#include <rinterpreter.h>

Collaboration diagram for RInterpreter:
[legend]

Public Member Functions

void Exec (const RString &insts)
 
RCursor< RPrgClassGetClasses (void) const
 
 RInterpreter (RPrgOutput *o)
 
void Run (const RURI &uri)
 
virtual ~RInterpreter (void)
 

Protected Member Functions

void AddClass (RPrgClass *c)
 
void AddInst (RPrgInst *inst)
 
void AddVar (RPrgVar *var)
 
void AnalyzeParams (void)
 
void CleanupParams (void)
 
void DelVar (RPrgVar *var)
 
void Eol (bool dbl)
 
void Exec (void)
 
RPrgVarFind (const RString &name) const
 
size_t GetLine (void) const
 
RString GetToken (const RString chars)
 
virtual RString GetValue (const RString &var)
 
RString GetWord (void)
 
RString ReadLiteral (void)
 
void SkipSpaces (void)
 
void TreatInst (const RString &inst, size_t depth, RChar param)
 
void TreatLine (size_t depth, RString line)
 
RString WhatTreated (void) const
 

Protected Attributes

const RCharChar
 
RContainer< RPrgClass, true,
false > 
Classes
 
RPrgOutputCout
 
RURI File
 
size_t Line
 
RContainer< RPrgVar, false, false > Parameters
 
RStack< RPrgScope, true, true,
true > 
Scopes
 
RContainer< RPrgInstSub, false,
true > 
Subroutines
 
RStack< RPrgInstBlock, false,
true, true > 
tmpBlocks
 

Detailed Description

Script Program.

The RInterpreter provides a class for executing a script program.

Constructor & Destructor Documentation

Constructor of a program.

Parameters
oOutput.
virtual ~RInterpreter ( void  )
virtual

Destruct of the program.

Member Function Documentation

void Run ( const RURI uri)

Run a program.

Parameters
uriURI of the program.
void Exec ( const RString insts)

Execute a block of instructions.

Parameters
instsInstruction.
void Exec ( void  )
protected

Execute the instructions.

RString WhatTreated ( void  ) const
protected

Return a string of the form "filename(line)" representing the current element treated.

void AddVar ( RPrgVar var)
protected

Add a variable.

Parameters
varPointer to the variable.
void DelVar ( RPrgVar var)
protected

Remove a variable.

Parameters
varPointer to the variable.
void AddInst ( RPrgInst inst)
protected

Add an instruction.

Parameters
instInstruction.
RPrgVar* Find ( const RString name) const
protected

Find a variable by searching in all local blocks.

Parameters
nameName of the variable.
Returns
Pointer to the variable or 0 if not found.
virtual RString GetValue ( const RString var)
protectedvirtual

Get the value of the variable.

Parameters
varName of the variable.
void AddClass ( RPrgClass c)
protected

Add a class to the interpreter.

Parameters
cClass to add.
RCursor<RPrgClass> GetClasses ( void  ) const

Get a cursor over the classes.

void TreatLine ( size_t  depth,
RString  line 
)
protected

Load the script file.

void TreatInst ( const RString inst,
size_t  depth,
RChar  param 
)
protected

Treat instructions

Parameters
inst
depth
param
void AnalyzeParams ( void  )
protected

Analyze the parameters. Put the results in Parameters.

void CleanupParams ( void  )
protected

Cleanup the parameters if necessary.

RString ReadLiteral ( void  )
protected

Read a literal value.

RString GetWord ( void  )
protected

Get the next word at the line containing the instruction.

RString GetToken ( const RString  chars)
protected

Get the next token at the line containing the instruction.

void Eol ( bool  dbl)
protected

Treat end of line.

Parameters
dblMust the line contains a double point.
size_t GetLine ( void  ) const
protected

Line number of the current instruction.

void SkipSpaces ( void  )
protected

Skip the spaces.

Member Data Documentation

RPrgOutput* Cout
protected

Generic output.

RContainer<RPrgClass,true,false> Classes
protected

List of all "Classes" defined in the program.

RContainer<RPrgInstSub,false,true> Subroutines
protected

Subroutines defined in the program.

RStack<RPrgInstBlock,false,true,true> tmpBlocks
protected

Temporary LIFO Stack of instructions blocks (used for analyze).

RStack<RPrgScope,true,true,true> Scopes
protected

LIFO Stack of scopes.

RContainer<RPrgVar,false,false> Parameters
protected

Parameters actually treated.

const RChar* Char
protected

Next character to treat.

size_t Line
protected

Number of the line where the last instruction begins.

RURI File
protected

Name of the file.