aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2015-02-21 19:24:18 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2015-02-21 19:54:22 +0100
commit611bb221a96e50fd8561886ec34d8a42e136b5ce (patch)
treefc1a991b454100c89bb8e43e60f18edb0493f39f /src
parent99abf0775bc4df4f228bab20d23da580952a7423 (diff)
downloadsciteco-611bb221a96e50fd8561886ec34d8a42e136b5ce.tar.gz
throw error instead of assertion when loop is closed (>) or continued (F>) without a corresponding loop start (<)
* assertions were introduced very early when there was no proper error handling in SciTECO. However it points to a macro programming error instead of a SciTECO programming error and should not crash the editor. * Perhaps it would be best to check for this kind of "syntax" error also in parse-only modes. This is not done currently. * part of the solution to issue #3
Diffstat (limited to 'src')
-rw-r--r--src/parser.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index e5d1f22..384c42d 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -858,7 +858,9 @@ StateStart::custom(gchar chr)
tecoInt loop_pc, loop_cnt;
expressions.discard_args();
- g_assert(expressions.pop_op() == Expressions::OP_LOOP);
+ if (expressions.pop_op() != Expressions::OP_LOOP)
+ throw Error("Loop end without corresponding "
+ "loop start command");
loop_pc = expressions.pop_num();
loop_cnt = expressions.pop_num();
@@ -1482,6 +1484,9 @@ StateFCommand::custom(gchar chr)
* In interactive mode, if the loop is incomplete and must
* be exited, you can type in the loop's remaining commands
* without them being executed (but they are parsed).
+ *
+ * Calling \fBF\>\fP outside of a loop will throw an
+ * error.
*/
case '>': {
tecoInt loop_pc, loop_cnt;
@@ -1489,7 +1494,9 @@ StateFCommand::custom(gchar chr)
BEGIN_EXEC(&States::start);
/* FIXME: what if in brackets? */
expressions.discard_args();
- g_assert(expressions.pop_op() == Expressions::OP_LOOP);
+ if (expressions.pop_op() != Expressions::OP_LOOP)
+ throw Error("Jump to loop end without corresponding "
+ "loop start command");
loop_pc = expressions.pop_num();
loop_cnt = expressions.pop_num();