Yate
ScriptParser Class Referenceabstract

Abstract script parser. More...

#include <yatescript.h>

Inheritance diagram for ScriptParser:
GenObject JsParser

Public Member Functions

virtual ~ScriptParser ()
 
virtual bool parse (const char *text, bool fragment=false, const char *file=0, int len=-1)=0
 
virtual bool parseFile (const char *name, bool fragment=false)
 
void clear ()
 
ScriptCodecode () const
 
void setMaxFileLen (unsigned int len)
 
unsigned int maxFileLen () const
 
virtual ScriptContextcreateContext () const
 
virtual ScriptRuncreateRunner (ScriptCode *code, ScriptContext *context=0, const char *title=0) const
 
ScriptRuncreateRunner (ScriptContext *context=0, const char *title=0) const
 
virtual bool callable (const String &name)
 
- Public Member Functions inherited from GenObject
 GenObject ()
 
virtual ~GenObject ()
 
virtual bool alive () const
 
virtual void destruct ()
 
virtual const StringtoString () const
 
virtual const StringtraceId () const
 
virtual void * getObject (const String &name) const
 
NamedCountergetObjCounter () const
 
NamedCountersetObjCounter (NamedCounter *counter)
 

Protected Member Functions

 ScriptParser ()
 
void setCode (ScriptCode *code)
 

Additional Inherited Members

- Static Public Member Functions inherited from GenObject
static void * getObject (const String &name, const GenObject *obj)
 
static bool getObjCounting ()
 
static void setObjCounting (bool enable)
 
static NamedCountergetObjCounter (const String &name, bool create=true)
 
static ObjListgetObjCounters ()
 

Detailed Description

Abstract script parser.

Abstract parser, base class for each language parser

Constructor & Destructor Documentation

◆ ~ScriptParser()

virtual ~ScriptParser ( )
virtual

Destructor, releases code

◆ ScriptParser()

ScriptParser ( )
inlineprotected

Default constructor for derived classes

Member Function Documentation

◆ callable()

virtual bool callable ( const String & name)
virtual

Check if a script has a certain function or method

Parameters
nameName of the function to check
Returns
True if function exists in code

Reimplemented in JsParser.

◆ clear()

void clear ( )
inline

Clear any existing parsed code

References setCode().

◆ code()

ScriptCode * code ( ) const
inline

Retrieve the currently stored parsed code

Returns
Parsed code block, may be NULL

Referenced by JsParser::createRunner(), JsParser::createRunner(), createRunner(), createRunner(), and setCode().

◆ createContext()

virtual ScriptContext * createContext ( ) const
virtual

Create a context adequate for the parsed code

Returns
A new script context

Reimplemented in JsParser.

◆ createRunner() [1/2]

virtual ScriptRun * createRunner ( ScriptCode * code,
ScriptContext * context = 0,
const char * title = 0 ) const
virtual

Create a runner adequate for a block of parsed code

Parameters
codeParsed code block
contextScript context, an empty one will be allocated if NULL
titleAn optional name for the runner
Returns
A new script runner, NULL if code is NULL

Reimplemented in JsParser.

References code().

Referenced by createRunner().

◆ createRunner() [2/2]

ScriptRun * createRunner ( ScriptContext * context = 0,
const char * title = 0 ) const
inline

Create a runner adequate for the parsed code

Parameters
contextScript context, an empty one will be allocated if NULL
titleAn optional name for the runner
Returns
A new script runner, NULL if code is not yet parsed

References code(), and createRunner().

◆ maxFileLen()

unsigned int maxFileLen ( ) const
inline

Retrieve the maximum loadable file size

Returns
The maximum number of octets that will be loaded from a file

◆ parse()

virtual bool parse ( const char * text,
bool fragment = false,
const char * file = 0,
int len = -1 )
pure virtual

Parse a string as script source code

Parameters
textSource code text
fragmentTrue if the code is just an included fragment
fileName of the file that is being parsed
lenLength of text, negative if unknown
Returns
True if the text was successfully parsed

Implemented in JsParser.

◆ parseFile()

virtual bool parseFile ( const char * name,
bool fragment = false )
virtual

Parse a file as script source code

Parameters
nameSource file name
fragmentTrue if the code is just an included fragment
Returns
True if the file was successfully parsed

◆ setCode()

void setCode ( ScriptCode * code)
protected

Set the just parsed block of code

Parameters
codeParsed code block, may be NULL

References code().

Referenced by clear().

◆ setMaxFileLen()

void setMaxFileLen ( unsigned int len)
inline

Set the maximum loaded file length

Parameters
lenNew maximum file length

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