From bc75df4d582ba64e4809ea082337a3a0a5de9684 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Sat, 1 Oct 2011 10:19:45 -0600 Subject: [PATCH] Fixed parsing of block statements vs initializer expressions. --- include/chaiscript/language/chaiscript_parser.hpp | 12 ++++++------ include/chaiscript/language/chaiscript_prelude.hpp | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/chaiscript/language/chaiscript_parser.hpp b/include/chaiscript/language/chaiscript_parser.hpp index c176f6e..5b165c5 100644 --- a/include/chaiscript/language/chaiscript_parser.hpp +++ b/include/chaiscript/language/chaiscript_parser.hpp @@ -1605,7 +1605,7 @@ namespace chaiscript retval = true; Container_Arg_List(); if (!Char('}')) { - throw exception::eval_error("Missing closing square bracket", File_Position(m_line, m_col), *m_filename); + throw exception::eval_error("Missing closing curly bracket", File_Position(m_line, m_col), *m_filename); } if ((prev_stack_top != m_match_stack.size()) && (m_match_stack.back()->children.size() > 0)) { if (m_match_stack.back()->children[0]->identifier == AST_Node_Type::Value_Range) { @@ -1977,6 +1977,11 @@ namespace chaiscript retval = true; saw_eol = false; } + else if (Block()) { + has_more = true; + retval = true; + saw_eol = true; + } else if (Equation()) { if (!saw_eol) { throw exception::eval_error("Two expressions missing line separator", File_Position(prev_line, prev_col), *m_filename); @@ -1990,11 +1995,6 @@ namespace chaiscript retval = true; saw_eol = true; } - else if (Block()) { - has_more = true; - retval = true; - saw_eol = true; - } else { has_more = false; } diff --git a/include/chaiscript/language/chaiscript_prelude.hpp b/include/chaiscript/language/chaiscript_prelude.hpp index b96aba4..9cdecaf 100644 --- a/include/chaiscript/language/chaiscript_prelude.hpp +++ b/include/chaiscript/language/chaiscript_prelude.hpp @@ -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\ + return {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\