diff options
author | Benjamin Barenblat <bbaren@mit.edu> | 2015-08-26 17:29:32 -0400 |
---|---|---|
committer | Benjamin Barenblat <bbaren@mit.edu> | 2015-08-26 17:29:32 -0400 |
commit | bc6b0bee8fe4120642029daaa8ce6c069ef667b8 (patch) | |
tree | fab27db4556318e4f6a4b7c60e6b47c7ab58e59a /src/regex__FFI.h | |
parent | 75ff1a7a1979466a77dcc3acbbb88e897213027f (diff) |
Rework replacement API to rely on transformation
Redesign library API around highly general regex-based transformations.
Instead of specifying a string to substitute for each match, you
now execute an entire function over the match (and over nonmatching
regions as well). The resulting C++ code is much simpler, with more
functionality pushed into Ur, and the engine now supports certain
types of regex transformations needed to mimic Perl.
Diffstat (limited to 'src/regex__FFI.h')
-rw-r--r-- | src/regex__FFI.h | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/src/regex__FFI.h b/src/regex__FFI.h index 84b81a9..7399005 100644 --- a/src/regex__FFI.h +++ b/src/regex__FFI.h @@ -26,27 +26,28 @@ extern "C" { #include <urweb/urweb_cpp.h> typedef struct { - char* haystack; - void* result; -} uw_Regex__FFI_match; + long start; + long length; +} uw_Regex__FFI_substring_t; -uw_Basis_bool uw_Regex__FFI_succeeded(struct uw_context*, - const uw_Regex__FFI_match); +typedef void* uw_Regex__FFI_substring_list_t; -uw_Basis_int uw_Regex__FFI_n_subexpression_matches(struct uw_context*, - const uw_Regex__FFI_match); +uw_Basis_int uw_Regex__FFI_substring_start(struct uw_context*, + const uw_Regex__FFI_substring_t); -uw_Basis_string uw_Regex__FFI_subexpression_match(struct uw_context*, - const uw_Regex__FFI_match, - const uw_Basis_int); +uw_Basis_int uw_Regex__FFI_substring_length(struct uw_context*, + const uw_Regex__FFI_substring_t); -uw_Regex__FFI_match uw_Regex__FFI_do_match(struct uw_context*, - const uw_Basis_string, - const uw_Basis_string); +uw_Basis_int uw_Regex__FFI_substring_list_length( + struct uw_context*, const uw_Regex__FFI_substring_list_t); -uw_Basis_string uw_Regex__FFI_replace(struct uw_context*, const uw_Basis_string, - const uw_Basis_string, - const uw_Basis_string); +uw_Regex__FFI_substring_t uw_Regex__FFI_substring_list_get( + struct uw_context*, const uw_Regex__FFI_substring_list_t, + const uw_Basis_int); + +uw_Regex__FFI_substring_list_t uw_Regex__FFI_do_match(struct uw_context*, + const uw_Basis_string, + const uw_Basis_string); #ifdef __cplusplus } |