PikaScript
|
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< StdConfig > | StdScript |
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:
| |
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 > | |
S | 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 > | |
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 > | |
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 > | |
S | escape (const S &s) |
Depending on the contents of the source string s it is encoded either in single (' ') or double (" ") quotes. More... | |
The PikaScript namespace.
typedef Script< StdConfig > Pika::StdScript |
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.
enum Pika::Precedence |
Precedence levels are used both internally for the parser and externally for the tracing mechanism.
Definition at line 229 of file PikaScript.h.
enum Pika::Precedence |
Precedence levels are used both internally for the parser and externally for the tracing mechanism.
Definition at line 229 of file PikaScript.h.
|
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:
can be replaced with
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.
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.
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.
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.
S Pika::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.
radix
can be anything between 1 (binary) and 16 (hexadecimal).
Definition at line 117 of file PikaScriptImpl.h.
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.
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.
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.
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:
. 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.