-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #956 from andrew-johnson-4/regex-syntax
Regex syntax
- Loading branch information
Showing
14 changed files
with
20,204 additions
and
19,868 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
llA..bc..Fde | ||
llA..bcD..de |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
import regex.h; | ||
|
||
atom suffix Regex _rgx; | ||
|
||
.rm_so := λ: Blob(: t C_regmatch__t_). (: ( | ||
(:frame( (:frame t) )) | ||
(:expression( '\[_l (:expression t) '.rm_so\]_l )) | ||
) U64); | ||
.rm_eo := λ: Blob(: t C_regmatch__t_). (: ( | ||
(:frame( (:frame t) )) | ||
(:expression( '\[_l (:expression t) '.rm_eo\]_l )) | ||
) U64); | ||
|
||
.has-prefix := λ(: text SmartString)(: rgx Regex). (: ( | ||
(let status (regexec( | ||
(as (& rgx) C_regex__t_*_) | ||
(as (.start text) C_char_*) | ||
(as 0_u64 C_size__t_) | ||
(as 0_u64 C_regmatch__t_*) | ||
(as 0_u64 C_int) | ||
))) | ||
(==( (as status U64) 0_u64 )) | ||
) U64); | ||
|
||
.remove-prefix := λ(: text SmartString)(: rgx Regex). (: ( | ||
(let matches (as (malloc(sizeof C_regmatch__t_)) C_regmatch__t_[])) | ||
(let status (regexec( | ||
(as (& rgx) C_regex__t_*_) | ||
(as (.start text) C_char_*) | ||
(as 1_u64 C_size__t_) | ||
(as matches C_regmatch__t_*) | ||
(as 0_u64 C_int) | ||
))) | ||
(if (!=( (.rm_so([]( matches 0_u64 ))) 0_u64 )) ( | ||
(fail 'Remove\sSmartString\sPrefix\sBy\sRegex\sNot\sA\sPrefix_s) | ||
) ()) | ||
([:]( text 0_i64 (as (.rm_eo([]( matches 0_u64 ))) I64) )) | ||
) SmartString); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters