diff options
| author | Feoramund <161657516+Feoramund@users.noreply.github.com> | 2024-08-04 18:55:54 -0400 |
|---|---|---|
| committer | Feoramund <161657516+Feoramund@users.noreply.github.com> | 2024-08-04 18:56:29 -0400 |
| commit | dde42f0ebcef9dd7741761e6a7cc5ba738b63320 (patch) | |
| tree | 6599a6d1c2d79cf6c98c502164787e566691faa9 /core/text/regex/regex.odin | |
| parent | ca7e46d56f54b33bb3ac630ead662c327733774d (diff) | |
Add more documentation for `core:text/regex` API
Diffstat (limited to 'core/text/regex/regex.odin')
| -rw-r--r-- | core/text/regex/regex.odin | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/core/text/regex/regex.odin b/core/text/regex/regex.odin index a4bd4292e..0d8a1d9c0 100644 --- a/core/text/regex/regex.odin +++ b/core/text/regex/regex.odin @@ -13,22 +13,43 @@ Compiler_Error :: compiler.Error Creation_Error :: enum { None, + // A `\` was supplied as the delimiter to `create_by_user`. Bad_Delimiter, + // A pair of delimiters for `create_by_user` was not found. Expected_Delimiter, + // An unknown letter was supplied to `create_by_user` after the last delimiter. Unknown_Flag, } Error :: union #shared_nil { + // An error that can occur in the pattern parsing phase. + // + // Most of these are regular expression syntax errors and are either + // context-dependent as to what they mean or have self-explanatory names. Parser_Error, + // An error that can occur in the pattern compiling phase. + // + // Of the two that can be returned, they have to do with exceeding the + // limitations of the Virtual Machine. Compiler_Error, + // An error that occurs only for `create_by_user`. Creation_Error, } +/* +This struct corresponds to a set of string captures from a RegEx match. + +`pos` will contain the start and end positions for each string in `groups`, +such that `str[pos[0][0]:pos[0][1]] == groups[0]`. +*/ Capture :: struct { pos: [][2]int, groups: []string, } +/* +A compiled Regular Expression value, to be used with the `match_*` procedures. +*/ Regular_Expression :: struct { flags: Flags `fmt:"-"`, class_data: []virtual_machine.Rune_Class_Data `fmt:"-"`, |