PikaScript
Classes | Typedefs | Enumerations | Functions
Pika Namespace Reference

The PikaScript namespace. More...

Classes

class  bound_mem_fun_t
 bound_mem_fun_t is a member functor bound to a specific C++ object through a pointer. More...
 
class  Dumb
 We use this dummy class to specialize member functions for arbitrary types (including void, references etc). More...
 
class  Exception
 The PikaScript exception class. More...
 
class  QuickVars
 
struct  Script
 Script is a meta-class that groups all the core classes of the PikaScript interpreter together (except for the value class). More...
 
struct  StdConfig
 StdConfig is a configuration class for Script that uses the reference implementations of STLValue and Script::STLVariables. More...
 
class  STLValue
 STLValue is the reference implementation of a PikaScript variable. More...
 

Typedefs

typedef Script< StdConfigStdScript
 This typedef exist for your convenience. More...
 

Enumerations

enum  Precedence {
  NO_TRACE = 0, TRACE_ERROR = 1, TRACE_CALL = 2, TRACE_LOOP = 3,
  STATEMENT = 4, BODY = 5, ARGUMENT = 6, BRACKETS = 7,
  ASSIGN = 8, LOGICAL_OR = 9, LOGICAL_AND = 10, BIT_OR = 11,
  BIT_XOR = 12, BIT_AND = 13, EQUALITY = 14, COMPARE = 15,
  CONCAT = 16, SHIFT = 17, ADD_SUB = 18, MUL_DIV = 19,
  PREFIX = 20, POSTFIX = 21, DEFINITION = 22, NO_TRACE = 0,
  TRACE_ERROR = 1, TRACE_CALL = 2, TRACE_LOOP = 3, STATEMENT = 4,
  BODY = 5, ARGUMENT = 6, BRACKETS = 7, ASSIGN = 8,
  LOGICAL_OR = 9, LOGICAL_AND = 10, BIT_OR = 11, BIT_XOR = 12,
  BIT_AND = 13, EQUALITY = 14, COMPARE = 15, CONCAT = 16,
  SHIFT = 17, ADD_SUB = 18, MUL_DIV = 19, PREFIX = 20,
  POSTFIX = 21, DEFINITION = 22
}
 Precedence levels are used both internally for the parser and externally for the tracing mechanism. More...
 
enum  Precedence {
  NO_TRACE = 0, TRACE_ERROR = 1, TRACE_CALL = 2, TRACE_LOOP = 3,
  STATEMENT = 4, BODY = 5, ARGUMENT = 6, BRACKETS = 7,
  ASSIGN = 8, LOGICAL_OR = 9, LOGICAL_AND = 10, BIT_OR = 11,
  BIT_XOR = 12, BIT_AND = 13, EQUALITY = 14, COMPARE = 15,
  CONCAT = 16, SHIFT = 17, ADD_SUB = 18, MUL_DIV = 19,
  PREFIX = 20, POSTFIX = 21, DEFINITION = 22, NO_TRACE = 0,
  TRACE_ERROR = 1, TRACE_CALL = 2, TRACE_LOOP = 3, STATEMENT = 4,
  BODY = 5, ARGUMENT = 6, BRACKETS = 7, ASSIGN = 8,
  LOGICAL_OR = 9, LOGICAL_AND = 10, BIT_OR = 11, BIT_XOR = 12,
  BIT_AND = 13, EQUALITY = 14, COMPARE = 15, CONCAT = 16,
  SHIFT = 17, ADD_SUB = 18, MUL_DIV = 19, PREFIX = 20,
  POSTFIX = 21, DEFINITION = 22
}
 Precedence levels are used both internally for the parser and externally for the tracing mechanism. More...
 

Functions

template<class C , class A0 , class R >
bound_mem_fun_t< C, A0, R > bound_mem_fun (R(C::*m)(A0), C *o)
 bound_mem_fun creates a member functor bound to a specific C++ object through a pointer. More...
 

Conversion routines for string <-> other types.

For some of these we could use stdlib implementations yes, but:

  1. Some of them (e.g. atof, strtod) behaves differently depending on global "locale" setting. We can't have that.
  2. The stdlib implementations can be slow (e.g. my double->string conversion is about 3 times faster than MSVC CRT).
  3. Pika requires high-precision string representation and proper handling of trailing 9's etc.
template<class S >
std::string toStdString (const S &s)
 Converts the string s to a standard C++ string. More...
 
template<class S >
ulong hexToLong (typename S::const_iterator &p, const typename S::const_iterator &e)
 Converts a string in hexadecimal form to an ulong integer. More...
 
template<class S >
long stringToLong (typename S::const_iterator &p, const typename S::const_iterator &e)
 Converts a string in decimal form to a signed long integer. More...
 
template<class S , typename T >
intToString (T i, int radix=10, int minLength=1)
 Converts the integer i to a string with a radix and minimum length of your choice. More...
 
template<class S >
double stringToDouble (typename S::const_iterator &p, const typename S::const_iterator &e)
 Converts a string in scientific e notation (e.g. -12.34e-3) to a double floating point value. More...
 
template<class S >
bool stringToDouble (const S &s, double &d)
 A convenient utility routine that tries to convert the entire string s (in scientific e notation) to a double, returning true on success or false if the string is not in valid syntax.
 
template<class S >
doubleToString (double d, int precision=14)
 Converts the double d to a string (in scientific e notation, e.g. -12.34e-3). More...
 
template<class S >
unescape (typename S::const_iterator &p, const typename S::const_iterator &e)
 Converts a string that is either enclosed in single (' ') or double (" ") quotes. More...
 
template<class S >
escape (const S &s)
 Depending on the contents of the source string s it is encoded either in single (' ') or double (" ") quotes. More...
 

Detailed Description

The PikaScript namespace.

Typedef Documentation

This typedef exist for your convenience.

If you wish to use the reference implementation of PikaScript you can now simply instantiate Pika::StdScript::FullRoot and off you go.

Definition at line 583 of file PikaScript.h.

Enumeration Type Documentation

Precedence levels are used both internally for the parser and externally for the tracing mechanism.

Enumerator
NO_TRACE 

used only for tracing with tick()

TRACE_ERROR 

used only for tracing with tick()

TRACE_CALL 

used only for tracing with tick()

TRACE_LOOP 

used only for tracing with tick()

STATEMENT 

x; y;

BODY 

if () x, for () x

ARGUMENT 

(x, y)

BRACKETS 

(x) [x]

ASSIGN 

x=y x*=y x/=y x\=y x%=y x+=y x-=y x<<=y x>>=y x#=y x&=y x^=y x|=y

LOGICAL_OR 

x||y

LOGICAL_AND 

x&&y

BIT_OR 

x|y

BIT_XOR 

x^y

BIT_AND 

x&y

EQUALITY 

x===y x==y x!==y x!=y

COMPARE 

x<y x<=y x>y x>=y

CONCAT 

x::y

SHIFT 

x<<y x>>y

ADD_SUB 

x+y x-y

MUL_DIV 

x*y x/y x xy

PREFIX 

@x !x ~x +x -x ++x –x

POSTFIX 

x() x.y x[y] x{y} x++ x–

DEFINITION 

function { }

NO_TRACE 

used only for tracing with tick()

TRACE_ERROR 

used only for tracing with tick()

TRACE_CALL 

used only for tracing with tick()

TRACE_LOOP 

used only for tracing with tick()

STATEMENT 

x; y;

BODY 

if () x, for () x

ARGUMENT 

(x, y)

BRACKETS 

(x) [x]

ASSIGN 

x=y x*=y x/=y x\=y x%=y x+=y x-=y x<<=y x>>=y x#=y x&=y x^=y x|=y

LOGICAL_OR 

x||y

LOGICAL_AND 

x&&y

BIT_OR 

x|y

BIT_XOR 

x^y

BIT_AND 

x&y

EQUALITY 

x===y x==y x!==y x!=y

COMPARE 

x<y x<=y x>y x>=y

CONCAT 

x::y

SHIFT 

x<<y x>>y

ADD_SUB 

x+y x-y

MUL_DIV 

x*y x/y x xy

PREFIX 

@x !x ~x +x -x ++x –x

POSTFIX 

x() x.y x[y] x{y} x++ x–

DEFINITION 

function { }

Definition at line 229 of file PikaScript.h.

Precedence levels are used both internally for the parser and externally for the tracing mechanism.

Enumerator
NO_TRACE 

used only for tracing with tick()

TRACE_ERROR 

used only for tracing with tick()

TRACE_CALL 

used only for tracing with tick()

TRACE_LOOP 

used only for tracing with tick()

STATEMENT 

x; y;

BODY 

if () x, for () x

ARGUMENT 

(x, y)

BRACKETS 

(x) [x]

ASSIGN 

x=y x*=y x/=y x\=y x%=y x+=y x-=y x<<=y x>>=y x#=y x&=y x^=y x|=y

LOGICAL_OR 

x||y

LOGICAL_AND 

x&&y

BIT_OR 

x|y

BIT_XOR 

x^y

BIT_AND 

x&y

EQUALITY 

x===y x==y x!==y x!=y

COMPARE 

x<y x<=y x>y x>=y

CONCAT 

x::y

SHIFT 

x<<y x>>y

ADD_SUB 

x+y x-y

MUL_DIV 

x*y x/y x xy

PREFIX 

@x !x ~x +x -x ++x –x

POSTFIX 

x() x.y x[y] x{y} x++ x–

DEFINITION 

function { }

NO_TRACE 

used only for tracing with tick()

TRACE_ERROR 

used only for tracing with tick()

TRACE_CALL 

used only for tracing with tick()

TRACE_LOOP 

used only for tracing with tick()

STATEMENT 

x; y;

BODY 

if () x, for () x

ARGUMENT 

(x, y)

BRACKETS 

(x) [x]

ASSIGN 

x=y x*=y x/=y x\=y x%=y x+=y x-=y x<<=y x>>=y x#=y x&=y x^=y x|=y

LOGICAL_OR 

x||y

LOGICAL_AND 

x&&y

BIT_OR 

x|y

BIT_XOR 

x^y

BIT_AND 

x&y

EQUALITY 

x===y x==y x!==y x!=y

COMPARE 

x<y x<=y x>y x>=y

CONCAT 

x::y

SHIFT 

x<<y x>>y

ADD_SUB 

x+y x-y

MUL_DIV 

x*y x/y x xy

PREFIX 

@x !x ~x +x -x ++x –x

POSTFIX 

x() x.y x[y] x{y} x++ x–

DEFINITION 

function { }

Definition at line 229 of file PikaScript.h.

Function Documentation

template<class C , class A0 , class R >
bound_mem_fun_t< C, A0, R > Pika::bound_mem_fun ( R(C::*)(A0)  m,
C *  o 
)
inline

bound_mem_fun creates a member functor bound to a specific C++ object through a pointer.

You may use this function instead of "manually" binding a std::mem_fun functor to an object. For example the following code:

std::bind1st(std::mem_fun(&Dancer::tapDance), fredAstaire)));

can be replaced with

bound_mem_fun(&Dancer::tapDance, fredAstaire);

Furthermore, bound_mem_fun does not suffer from a problem that some STL implementations has which prevents you from using member functors with reference arguments.

bound_mem_fun is used in PikaScript to directly bind a native function to a member function of a certain C++ object.

Definition at line 120 of file PikaScript.h.

template<class S >
S Pika::doubleToString ( double  d,
int  precision = 14 
)

Converts the double d to a string (in scientific e notation, e.g. -12.34e-3).

precision can be between 1 and 24 and is the number of digits to include in the output string (not counting any exponent of course). Any trailing decimal zeroes will be trimmed and only significant digits will be included.

Definition at line 157 of file PikaScriptImpl.h.

template<class S >
S Pika::escape ( const S &  s)

Depending on the contents of the source string s it is encoded either in single (' ') or double (" ") quotes.

If the string contains only printable ASCII chars (ASCII values between 32 and 126 inclusively) and no apostrophes (' '), it is enclosed in single quotes with no further processing. Otherwise it is enclosed in double quotes (" ") and any unprintable ASCII character, backslash () or quotation mark (") is encoded using C-style escape sequences (e.g. \code "line1 " ).

Definition at line 225 of file PikaScriptImpl.h.

template<class S >
ulong Pika::hexToLong ( typename S::const_iterator &  p,
const typename S::const_iterator &  e 
)

Converts a string in hexadecimal form to an ulong integer.

p is updated on return to point to the first unparsed (e.g. invalid) character. If p == e, the full string was successfully converted.

Definition at line 101 of file PikaScriptImpl.h.

template<class S , typename T >
S Pika::intToString ( i,
int  radix = 10,
int  minLength = 1 
)

Converts the integer i to a string with a radix and minimum length of your choice.

radix can be anything between 1 (binary) and 16 (hexadecimal).

Definition at line 117 of file PikaScriptImpl.h.

template<class S >
double Pika::stringToDouble ( typename S::const_iterator &  p,
const typename S::const_iterator &  e 
)

Converts a string in scientific e notation (e.g. -12.34e-3) to a double floating point value.

Spaces before 'e' are not accepted. Uppercase 'E' is allowed. Positive and negative 'infinity' is supported (provided the compiler allows it).p is updated on return to point to the first unparsed (e.g. invalid) character. If p == e, the full string was successfully converted.

Definition at line 129 of file PikaScriptImpl.h.

template<class S >
long Pika::stringToLong ( typename S::const_iterator &  p,
const typename S::const_iterator &  e 
)

Converts a string in decimal form to a signed long integer.

p is updated on return to point to the first unparsed (e.g. invalid) character. If p == e, the full string was successfully converted.

Definition at line 109 of file PikaScriptImpl.h.

template<class S >
std::string Pika::toStdString ( const S &  s)

Converts the string s to a standard C++ string.

The default implementation is std::string(s.begin(), s.end()). You should specialize this template if necessary.

Definition at line 97 of file PikaScriptImpl.h.

template<class S >
S Pika::unescape ( typename S::const_iterator &  p,
const typename S::const_iterator &  e 
)

Converts a string that is either enclosed in single (' ') or double (" ") quotes.

The routine expects the string beginning at p to be of one of these forms, but e can point beyond the terminating quote. If the single (' ') quote is used, the string between the quotes is simply extracted "as is" with the exception of pairs of apostrophes ('') that are used to represent single apostrophes. If the string is enclosed in double quotes (" ") it can use C-style escape sequences. The supported escape sequences are:

\\ \" \' \a \b \f \n \r \t \v \xHH \uHHHH <decimal>

. On return, p will point to the first unparsed (e.g. invalid) character. If p == e, the full string was successfully converted.

Definition at line 198 of file PikaScriptImpl.h.