diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2013-03-28 18:33:13 +0100 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2014-02-15 15:21:52 +0100 |
commit | c6b6aefd36d49aaf873bca20175b929f828589df (patch) | |
tree | 47e46a9e6c869d9d50c27e0d436911cb8bd63ab9 /src/parser.cpp | |
parent | d374448af8ab690c810757f73ba44f208db96f30 (diff) | |
download | sciteco-c6b6aefd36d49aaf873bca20175b929f828589df.tar.gz |
String::get_coord() calculates line and column of a string position
* use to get line and column into a stack frame
Diffstat (limited to 'src/parser.cpp')
-rw-r--r-- | src/parser.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/parser.cpp b/src/parser.cpp index 016b8bd..8921942 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -89,6 +89,8 @@ Execute::step(const gchar *macro, gint stop_pos) State::input(macro[macro_pc]); } catch (State::Error &error) { error.pos = macro_pc; + String::get_coord(macro, error.pos, + error.line, error.column); throw; /* forward */ } macro_pc++; @@ -170,6 +172,8 @@ Execute::file(const gchar *filename, bool locals) macro(p, locals); } catch (State::Error &error) { error.pos += p - macro_str; + if (*macro_str == '#') + error.line++; error.add_frame(new State::Error::FileFrame(filename)); g_free(macro_str); @@ -191,7 +195,8 @@ ReplaceCmdline::ReplaceCmdline() pos++; } -State::Error::Error(const gchar *fmt, ...) : frames(NULL), pos(0) +State::Error::Error(const gchar *fmt, ...) + : frames(NULL), pos(0), line(0), column(0) { va_list ap; @@ -201,6 +206,16 @@ State::Error::Error(const gchar *fmt, ...) : frames(NULL), pos(0) } void +State::Error::add_frame(Frame *frame) +{ + frame->pos = pos; + frame->line = line; + frame->column = column; + + frames = g_slist_prepend(frames, frame); +} + +void State::Error::display_short(void) { interface.msg(Interface::MSG_ERROR, |