]> git.xolatile.top Git - public-libhl.git/commitdiff
+new_region()
authoranon <anon@anon.anon>
Mon, 28 Aug 2023 13:39:16 +0000 (15:39 +0200)
committeranon <anon@anon.anon>
Mon, 28 Aug 2023 13:39:16 +0000 (15:39 +0200)
source/hl.h

index d927075cf16b4bfa9512263f8958a62de30489c7..462a024e6cdda795e161c2c70b7b6e38b78b81ad 100644 (file)
@@ -160,6 +160,26 @@ int new_keyword_tokens(const char       * const * words,
        return i;
 }
 
+token_t * new_region_token(const char       * const * start,
+                           const char       * const *   end,
+                                 hl_group_t * const       g) {
+       char buffer[100];
+       buffer[0] = '\0';
+       strcat(buffer, start);
+       strcat(buffer, "[\\d\\D]*");
+       strcat(buffer, end);
+
+       token_t * mt = (token_t*)malloc(sizeof(token_t));
+
+       mt->hl     = g;
+       mt->t      = KEYSYMBOL;
+       mt->syntax = regex_compile(buffer);
+
+       append_token(mt);
+
+       return mt;
+}
+
 token_t * new_token(const char         * const word,
                     const token_type_t            t,
                           hl_group_t   * const    g) {