From e5884ab2166ab5a03294baa54601b8785e6d9727 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Fri, 6 Dec 2024 17:20:52 +0300 Subject: support the ::S anchored search (string comparison) command (and ::FD, ::FR, ::FS as well) * The colon modifier can now occur 2 times. Specifying `@` more than once or `:` more than twice is an error now. * Commands do not check for excess colon modifiers - almost every command would have to check it. Instead, a double colon will simply behave like a single colon on most commands. * All search commands inherit the anchored semantics, but it's not very useful in some combinations like -::S, ::N or ::FK. That's why the `::` variants are not documented everywhere. * The lexer.checkheader macro could be simplified and should also be faster now, speeding up startup. Eventually this macro can be made superfluous, e.g. by using 1:FB or 0,1^Q::S. --- src/parser.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/parser.h') diff --git a/src/parser.h b/src/parser.h index 1127dcd..20f73fb 100644 --- a/src/parser.h +++ b/src/parser.h @@ -460,7 +460,12 @@ struct teco_machine_main_t { struct { teco_mode_t mode : 8; - bool modifier_colon : 1; + /** number of `:`-modifiers detected */ + guint modifier_colon : 2; + /** + * Whether the `@`-modifier has been detected. + * This is tracked even in parse-only mode. + */ bool modifier_at : 1; }; guint __flags; @@ -503,7 +508,7 @@ void teco_machine_main_init(teco_machine_main_t *ctx, teco_qreg_table_t *qreg_table_locals, gboolean must_undo); -gboolean teco_machine_main_eval_colon(teco_machine_main_t *ctx); +guint teco_machine_main_eval_colon(teco_machine_main_t *ctx); gboolean teco_machine_main_eval_at(teco_machine_main_t *ctx); gboolean teco_machine_main_step(teco_machine_main_t *ctx, -- cgit v1.2.3