aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/parser.c
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2025-04-08 23:26:38 +0300
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2025-04-09 00:33:40 +0300
commit7c0e4fbb1d1f0d19d11c7417c55a305654ab1c83 (patch)
tree35a99cefee7b63510f6765be4193b5a069c1eec2 /src/parser.c
parenta7e66807871c70a99909fcf78335309ae1505055 (diff)
downloadsciteco-7c0e4fbb1d1f0d19d11c7417c55a305654ab1c83.tar.gz
tightened rules for specifying modifiers
* Instead of separate stand-alone commands, they are now allowed only immediately in front of the commands that accept them. * The order is still insignificant if both `@` and `:` are accepted. * The number of colon modifiers is now also checked. We basically get this for free. * `@` has syntactic significance, so it could not be set conditionally anyway. Still, it was possible to provoke bugs were `@` was interpreted conditionally as in `@ 2<I/foo/$>`. * Even when not causing bugs, a mistyped `@` would often influence the __next__ command, causing unexpected behavior, for instance when typing `@(233C)W`. * While it was theoretically possible to set `:` conditionally, it could also be "passed through" accidentally to some command where it wasn't expected as in `:Ifoo$ C`. I do not know of any real useful application or idiom of a conditionally set `:`. If there would happen to be some kind of useful application, `:'` and `:|` could be re-allowed easily, though. * I was condidering introducing a common parser state for modified commands, but that would have been tricky and introduce a lot of redundant command lists. So instead, we now simply everywhere check for excess modifiers. To simplify this task, teco_machine_main_transition_t now contains flags signaling whether the transition is allowed with `@` or `:` modifiers set. It currently only has to be checked in the start state, after `E` and `F`.
Diffstat (limited to 'src/parser.c')
-rw-r--r--src/parser.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/parser.c b/src/parser.c
index f4f7595..044a741 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -355,6 +355,13 @@ teco_machine_main_transition_input(teco_machine_main_t *ctx,
return NULL;
}
+ if ((ctx->modifier_at && !transitions[chr].modifier_at) ||
+ (ctx->mode == TECO_MODE_NORMAL &&
+ ctx->modifier_colon > transitions[chr].modifier_colon)) {
+ teco_error_modifier_set(error, chr);
+ return NULL;
+ }
+
if (ctx->mode == TECO_MODE_NORMAL && transitions[chr].transition_cb) {
/*
* NOTE: We could also just let transition_cb return a boolean...