diff --git a/include/chaiscript/language/chaiscript_parser.hpp b/include/chaiscript/language/chaiscript_parser.hpp index 2c818abd..daf9782f 100644 --- a/include/chaiscript/language/chaiscript_parser.hpp +++ b/include/chaiscript/language/chaiscript_parser.hpp @@ -2278,6 +2278,16 @@ namespace chaiscript } build_match>(prev_stack_top); } + else if (Eol()) { + auto start = --m_position; + while (Eol()) {} + if (Symbol(".")) { + has_more = true; + --m_position; + } else { + m_position = start; + } + } } } diff --git a/unittests/multiline.chai b/unittests/multiline.chai index dfa213c3..f4cd9d9c 100644 --- a/unittests/multiline.chai +++ b/unittests/multiline.chai @@ -1,3 +1,14 @@ +class MyClass { + var value; + def MyClass(v) { this.value = v; } + def getWrappedIncrement() { return MyClass(this.value + 1); } + def getValue { return this.value; } +}; + +def foo(x) { + return MyClass(x+1); +} + auto x = [1, 2, 3, 4] @@ -7,3 +18,21 @@ auto y = map(x, fun(x) { x + 1 }) assert_equal(2, y[0]) + +auto z = foo(1) +.value + +assert_equal(2, z) + +auto v = foo(2) +.getValue() + +assert_equal(3, v) + +auto u = MyClass(3) +.getWrappedIncrement() + +.getWrappedIncrement() +.getValue() + +assert_equal(5, u) \ No newline at end of file