Merge branch '2011-09-09-CxScript' of https://github.com/ChaiScript/ChaiScript into 2011-09-09-CxScript

Conflicts:
	include/chaiscript/dispatchkit/bootstrap.hpp
This commit is contained in:
Jason Turner
2011-09-24 15:10:18 -06:00
57 changed files with 83 additions and 78 deletions

View File

@@ -406,7 +406,7 @@ namespace chaiscript
m->add(fun(&dispatch::Dynamic_Object::get_attrs), "get_attrs");
m->add(fun(&dispatch::Dynamic_Object::get_attr), "get_attr");
m->eval("def Dynamic_Object::clone() { auto &new_o = Dynamic_Object(this.get_type_name()); for_each(this.get_attrs(), bind(fun(new_o, x) { new_o.get_attr(x.first) = x.second; }, new_o, _) ); return new_o; }");
m->eval("def Dynamic_Object::clone() { auto &new_o = Dynamic_Object(this.get_type_name()); for_each(this.get_attrs(), bind([](new_o, x) { new_o.get_attr(x.first) = x.second; }, new_o, _) ); return new_o; }");
m->add(fun(&has_guard), "has_guard");
m->add(fun(&get_guard), "get_guard");

View File

@@ -1119,7 +1119,11 @@ namespace chaiscript
size_t prev_stack_top = m_match_stack.size();
if (Keyword("fun")) {
//if (Keyword("fun")) {
if (Char('[')) {
if (!Char(']')) {
throw exception::eval_error("Closure list not currently supported", File_Position(m_line, m_col), *m_filename);
}
retval = true;
if (Char('(')) {
@@ -1597,10 +1601,10 @@ namespace chaiscript
size_t prev_stack_top = m_match_stack.size();
if (Char('[')) {
if (Char('{')) {
retval = true;
Container_Arg_List();
if (!Char(']')) {
if (!Char('}')) {
throw exception::eval_error("Missing closing square bracket", File_Position(m_line, m_col), *m_filename);
}
if ((prev_stack_top != m_match_stack.size()) && (m_match_stack.back()->children.size() > 0)) {

View File

@@ -7,7 +7,7 @@
#ifndef CHAISCRIPT_PRELUDE_HPP_
#define CHAISCRIPT_PRELUDE_HPP_
//Note, the expression "[x,y]" in "collate" is parsed as two separate expressions
//Note, the expression "{x,y}" in "collate" is parsed as two separate expressions
//by C++, so CODE_STRING, takes two expressions and adds in the missing comma
#define CODE_STRING(x, y) #x ", " #y
@@ -23,7 +23,7 @@ def to_string(x) : call_exists(first, x) && call_exists(second, x) { \n\
}\n\
# to_string for containers\n\
def to_string(x) : call_exists(range, x) && !x.is_type("string"){ \n\
"[" + x.join(", ") + "]"; \n\
"{" + x.join(", ") + "}"; \n\
}\n\
# Basic to_string function\n\
def to_string(x) { \n\
@@ -259,7 +259,7 @@ def generate_range(x, y) { \n\
}\n\
# Returns a new Vector with the first value to the second value as its elements\n\
def collate(x, y) { \n\
[x, y]; \n\
{x, y}; \n\
} \n\
def zip_with(f, x, y, inserter) : call_exists(range, x) && call_exists(range, y) { \n\
auto r_x = range(x); \n\
@@ -305,10 +305,10 @@ def string::find_last_not_of(list) : is_type(list, "string") { \n\
int(find_last_not_of(this, list, -1)); \n\
} \n\
def string::ltrim() { \n\
drop_while(this, fun(x) { x == ' ' || x == '\t' || x == '\r' || x == '\n'}); \n\
drop_while(this, [](x) { x == ' ' || x == '\t' || x == '\r' || x == '\n'}); \n\
} \n\
def string::rtrim() { \n\
reverse(drop_while(reverse(this), fun(x) { x == ' ' || x == '\t' || x == '\r' || x == '\n'})); \n\
reverse(drop_while(reverse(this), [](x) { x == ' ' || x == '\t' || x == '\r' || x == '\n'})); \n\
} \n\
def string::trim() { \n\
ltrim(rtrim(this)); \n\