diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2014-11-20 03:51:56 +0100 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2014-11-20 03:51:56 +0100 |
commit | f843a090cdda120d58f968b7936bdcc53b61e323 (patch) | |
tree | a6866f1ebc4f28f7ace74e70a1d8fa87e47a63d0 | |
parent | c80c632ed2e844a66207da5fb462960ecca219f5 (diff) | |
download | sciteco-f843a090cdda120d58f968b7936bdcc53b61e323.tar.gz |
throw error when macro returns with an unterminated command
it was not possible to inherit the parser state of the last command in
a macro. However, it was possible to exit the macro when its
last command was not properly terminated.
There is no useful conscious application of this behaviour.
* If something like an uncomplete E-Command was last in the
macro, there was absolutely no effect. However this points
to a macro programming error.
* If the last command started a string parameter but did not
terminate it, the command might be (partially) executed.
However the State's done() method wasn't called, which means
that some commands will not execute at all. Again there's
no useful application of this.
When on the other hand, the last command was not terminated
by accident, this was not reported to the user.
-rw-r--r-- | src/parser.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/parser.cpp b/src/parser.cpp index 90447d4..0b11721 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -145,6 +145,7 @@ Execute::macro(const gchar *macro, bool locals) try { step(macro, strlen(macro)); + if (Goto::skip_label) { Error error("Label \"%s\" not found", Goto::skip_label); @@ -153,6 +154,18 @@ Execute::macro(const gchar *macro, bool locals) error.line, error.column); throw error; } + + if (States::current != &States::start) { + Error error("Unterminated command"); + /* + * can only happen if we returned because + * of macro end + */ + error.pos = strlen(macro); + String::get_coord(macro, error.pos, + error.line, error.column); + throw error; + } } catch (...) { g_free(Goto::skip_label); Goto::skip_label = NULL; |