aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2014-11-20 05:29:26 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2014-11-20 05:29:26 +0100
commitb0bc20bdeae770de3726f87d8ea13038491b2e29 (patch)
treeea48665e9aec8179c5320be37b4b1a565d12696b /src
parente909fb2179724b5619213520ca46cc31b4e6713b (diff)
downloadsciteco-b0bc20bdeae770de3726f87d8ea13038491b2e29.tar.gz
simplified attaching errors to a position in a macro
introduced Error::set_coord()
Diffstat (limited to 'src')
-rw-r--r--src/error.h7
-rw-r--r--src/parser.cpp11
2 files changed, 11 insertions, 7 deletions
diff --git a/src/error.h b/src/error.h
index 2786929..d0849c7 100644
--- a/src/error.h
+++ b/src/error.h
@@ -101,6 +101,13 @@ public:
Error(const Error &inst);
~Error();
+ inline void
+ set_coord(const gchar *str, gint _pos)
+ {
+ pos = _pos;
+ String::get_coord(str, pos, line, column);
+ }
+
void add_frame(Frame *frame);
void display_short(void);
diff --git a/src/parser.cpp b/src/parser.cpp
index 35b6add..98df598 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -104,9 +104,7 @@ Execute::step(const gchar *macro, gint stop_pos)
throw StdError(error);
}
} catch (Error &error) {
- error.pos = macro_pc;
- String::get_coord(macro, error.pos,
- error.line, error.column);
+ error.set_coord(macro, macro_pc);
throw; /* forward */
}
macro_pc++;
@@ -148,7 +146,8 @@ Execute::macro(const gchar *macro, bool locals)
/*
* Subsequent errors must still be
- * attached to this macro invocation.
+ * attached to this macro invocation
+ * via Error::set_coord()
*/
try {
if (Goto::skip_label)
@@ -173,9 +172,7 @@ Execute::macro(const gchar *macro, bool locals)
if (locals)
QRegisters::locals->clear();
} catch (Error &error) {
- error.pos = strlen(macro);
- String::get_coord(macro, error.pos,
- error.line, error.column);
+ error.set_coord(macro, strlen(macro));
throw; /* forward */
}
} catch (...) {