force strings to be finished

master
Daniel Kolesa 2016-09-20 22:32:46 +02:00
parent 43e272c7e0
commit 1b25b64ae5
2 changed files with 6 additions and 2 deletions

View File

@ -30,6 +30,7 @@ advantages, including:
* Modern C++14 API (no macros, strongly typed enums, lambdas, ranges etc.)
* C++14 lambdas can be used as commands (including captures and type inference)
* Error handling including recovery (protected call system similar to Lua)
* Stricter parsing (strings cannot be left unfinished)
* Loop control statements (`break` and `continue`)
* No manual memory mangement, values manage themselves
* Clean codebase that is easy to read and contribute to
@ -38,6 +39,7 @@ advantages, including:
There are some features that are a work in progress and will come later:
* More helpful debug information (proper line infos at both parse and run time)
* A degree of thread safety (see below)
* Custom allocator support (control over how heap memory is allocated)
* Coroutines

View File

@ -74,6 +74,7 @@ static ostd::ConstCharRange cs_parse_str(ostd::ConstCharRange str) {
}
ostd::ConstCharRange GenState::get_str() {
char const *ln = source;
char const *beg = source + 1;
source = beg;
for (; current(); next_char()) {
@ -92,9 +93,10 @@ ostd::ConstCharRange GenState::get_str() {
}
done:
auto ret = ostd::ConstCharRange(beg, source);
if (current() == '\"') {
next_char();
if (current() != '\"') {
cs_error_line(*this, ln, "unfinished string '%s'", ln);
}
next_char();
return ret;
}