diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-04-01 14:05:10 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-04-01 14:05:10 -0400 |
| commit | 4d59fc2987e52da0274e6b204a9d2885613f74b7 (patch) | |
| tree | 8c262f99cb6ae9b550b9f8abf0ab0477044d087a /src/stdlib/patterns.h | |
| parent | 7a2c99de74f5870e1dea5b59d049678ad0ef8e44 (diff) | |
Move patterns into a module
Diffstat (limited to 'src/stdlib/patterns.h')
| -rw-r--r-- | src/stdlib/patterns.h | 46 |
1 files changed, 0 insertions, 46 deletions
diff --git a/src/stdlib/patterns.h b/src/stdlib/patterns.h deleted file mode 100644 index 2b77e490..00000000 --- a/src/stdlib/patterns.h +++ /dev/null @@ -1,46 +0,0 @@ -#pragma once - -// The type representing text patterns for pattern matching. - -#include <stdbool.h> -#include <stdint.h> - -#include "datatypes.h" -#include "integers.h" -#include "optionals.h" -#include "types.h" - -#define Pattern(text) ((Pattern_t)Text(text)) -#define Patterns(...) ((Pattern_t)Texts(__VA_ARGS__)) - -typedef struct { - Text_t text; - Int_t index; - Array_t captures; -} Match_t; - -typedef Match_t OptionalMatch_t; -#define NONE_MATCH ((OptionalMatch_t){.index=NONE_INT}) - -Text_t Text$replace(Text_t str, Pattern_t pat, Text_t replacement, Pattern_t backref_pat, bool recursive); -Pattern_t Pattern$escape_text(Text_t text); -Text_t Text$replace_all(Text_t text, Table_t replacements, Pattern_t backref_pat, bool recursive); -Array_t Text$split(Text_t text, Pattern_t pattern); -Closure_t Text$by_split(Text_t text, Pattern_t pattern); -Text_t Text$trim(Text_t text, Pattern_t pattern, bool trim_left, bool trim_right); -OptionalMatch_t Text$find(Text_t text, Pattern_t pattern, Int_t i); -Array_t Text$find_all(Text_t text, Pattern_t pattern); -Closure_t Text$by_match(Text_t text, Pattern_t pattern); -PUREFUNC bool Text$has(Text_t text, Pattern_t pattern); -OptionalArray_t Text$matches(Text_t text, Pattern_t pattern); -Text_t Text$map(Text_t text, Pattern_t pattern, Closure_t fn, bool recursive); -void Text$each(Text_t text, Pattern_t pattern, Closure_t fn, bool recursive); - -#define Pattern$hash Text$hash -#define Pattern$compare Text$compare -#define Pattern$equal Text$equal - -extern const TypeInfo_t Match$info; -extern const TypeInfo_t Pattern$info; - -// vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1,\:0 |
